Global expansion, localizing content, and selling in multiple currencies and languages
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
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
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!
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:
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.
If your Shopify plan includes Markets, you can set Market-specific domains to serve different languages automatically:
This method is better because it’s officially supported by Shopify, and users won’t experience a manual redirect.
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.