How can I get Drupal 8 to use different landing pages for different countries?

I can create the pages but how do I tell Drupal which page to show for each country? Is geo location the only way, or is there another way?

  • If you are simply asking whenever you should use the geo location or another method, then this question is off-topic for us. The considerations to do don't change just because you are using Drupal.
    – apaderno
    Jul 27 '16 at 5:06

First thing is, how are you identifying your user's country?

  • You could use JS and the geolocation API
  • Or you could use the IP of the user and use a database

Id depends on how accurate you need this.
Once you translate the information to an actual country. Then you can decide what to show.


Something to keep in mind is the penalty for this. Instead of showing a different page per country, you might consider showing the same page and maybe via some JS modify an element once you have the location.

  • Thanks, I could use an IP of the country and then load the twig layer with a different rel would this stop the penalty? The database of ips is this stored in the Drupal website or a rest service of some sort?
    – purencool
    Jul 27 '16 at 3:29
  • You could use either :) You could use the GeoIP API module or you could use one of the many REST API's available online. For example, ip-api.com, freegeoip.net.
    – rovr138
    Jul 27 '16 at 20:50
  • Of course! Good luck.
    – rovr138
    Jul 28 '16 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.