We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

2 Domains - 2 Languages

2 Domains - 2 Languages

TBS2023
Shopify Partner
322 1 45

Hello

I have 2 domains set up for my site . One .se ( swedish) and one .dk (danish)

I would like  when a customer searches for the Danish website, he is redirected to the Danish language automatically and same for the Swedish.

It is the same website which a language selector at the top - but 2 domains - 

Main domain being the Swedish

Thanks

Reply 1 (1)

DaisyVo
Shopify Partner
4469 501 599

Hi @TBS2023 

I totally get what you’re trying to do. You have two domains—one for Sweden (.se) and one for Denmark (.dk)—but since it's the same website with a language selector, you want visitors to automatically see the correct language based on the domain they enter. That makes sense for user experience!

Solution: Auto-Redirect Based on Domain

Since Shopify doesn’t have built-in settings for this, you’ll need to use custom code in Liquid or redirect rules in your theme’s JavaScript. Here’s the best way to do it:

1. Use Liquid Code to Detect the Domain

You can modify your theme.liquid file to check the domain and automatically change the language. Add this code inside the <head> tag:

 

<script>

  document.addEventListener("DOMContentLoaded", function() {

    var domain = window.location.hostname;

    

    if (domain.includes("yourdomain.dk")) {

      window.location.href = "/?lang=da";  // Redirect to Danish

    } else if (domain.includes("yourdomain.se")) {

      window.location.href = "/?lang=sv";  // Redirect to Swedish

    }

  });

</script>

 

Make sure to replace yourdomain.dk and yourdomain.se with your actual domains.

2. If You’re Using Shopify Markets (Recommended)

If your Shopify plan includes Markets, you can set Market-specific domains to serve different languages automatically:

  1. Go to Settings > Markets in your Shopify Admin.
  2. Click on Manage next to Denmark and Sweden.
  3. Under Domains & Languages, assign the correct domain (.dk for Danish, .se for Swedish).
  4. Make sure the correct language is selected for each domain.

This method is better because it’s officially supported by Shopify, and users won’t experience a manual redirect.

Final Thoughts

If you want the smoothest experience, I highly recommend using Shopify Markets to handle the language switch automatically. But if that’s not an option, the JavaScript method will work fine.

Let me know if you need extra help. Just let me know asap. Thanks!
Daisy.

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution