Hreflang and multilingual stores in Shoporama
How Shoporama sets hreflang, x-default, and html lang for your countries, what happens to untranslated pages, and how to handle your own hreflang tags and separate stores.
If your store is available in several languages, hreflang tags tell Google which language versions of a page belong together. Google can then show the Swedish page to the Swedish customer and the Danish page to the Danish customer. If you sell in several countries with Countries, Shoporama adds hreflang tags automatically. Here you can see what Shoporama adds, what to do with hreflang tags you have added to your theme yourself, and how to use hreflang between two separate stores.
What is hreflang?
Hreflang is an HTML attribute on a link in the page's <head> section. It tells Google that the page exists in several languages and links to the other language versions. The code consists of a language and optionally a country, for example da-DK for Danish in Denmark or en-GB for English in the United Kingdom. You can read more about the term in the glossary under hreflang.
<link rel="alternate" hreflang="da-DK" href="https://dinshop.dk/mit-produkt"> <link rel="alternate" hreflang="en-GB" href="https://dinshop.dk/en/my-product"> <link rel="alternate" hreflang="x-default" href="https://dinshop.dk/mit-produkt">
Every language version must have the same set of links, including a link to itself. x-default is the version Google should show when none of the languages match the person searching.
Shoporama sets hreflang for your countries
If you have activated at least one country under Webshop → Countries, Shoporama adds hreflang tags to the <head> of your pages by itself. You don't need to do anything in the theme. It happens in the finished page, so it also works if you have your own theme. On a product, it might look like this:
<link rel="alternate" hreflang="da-DK" href="https://dinshop.dk/filterkaffe-moerkristet"> <link rel="alternate" hreflang="x-default" href="https://dinshop.dk/filterkaffe-moerkristet"> <link rel="alternate" hreflang="sv-SE" href="https://dinshop.dk/se/filterkaffe-morkrostat"> <link rel="alternate" hreflang="en-GB" href="https://dinshop.dk/uk/dark-roast-filter-coffee">
These are the rules:
- The main country and the active countries are included. Each version gets a code with the country's language and country code, for example sv-SE. If two countries share a language, for example Germany and Austria, they are distinguished by the country code.
- x-default points to the main country. That is your store as it is today.
- The links point to the same page in each country, using the page's translated URL. If you use a separate domain per country, they point to that country's domain.
- Countries that are not active are not included.
- Only pages that exist in at least two languages get hreflang tags, and a page that doesn't exist gets none.
Shoporama also sets the page's language in <html lang="...">, including in the main country, and changes the theme's og:locale to the country's, for example sv_SE. The page's canonical and all links on the page point to the country's own URL, and each country has its own sitemap, for example dinshop.dk/se/sitemap.xml.
Pages that haven't been translated yet
A product, category, landing page, page, or blog post counts as translated when it has a URL in the country's language. It gets one when its name is translated, either by the automatic translation or by you. Until then, the page is shown with Danish text in that country, and Shoporama does three things:
- The country's version is not included in the page's hreflang tags. If the page is only translated into one of your languages, only that version is included.
- The country's version gets <meta name="robots" content="noindex, follow">, so Google doesn't index the Danish text under the country's URL. After all, the page is already in Google from the main country.
- The page is not included in the country's sitemap.
Once the page is translated, it is added in all three places automatically. The same applies to the country's product feeds, for example Google Shopping, which only include the products that are translated into the country's language. Pages without their own URL, such as the front page and search, are always considered translated. You can keep track of what's missing under Webshop → Translations. Read more in Translate your store into other languages.
Have you added hreflang tags to your theme yourself?
Shoporama doesn't remove the hreflang tags in your theme. If you use Countries and have also added hreflang tags yourself, the page gets two sets, and if they don't say the same thing, Google can't know which one to trust. So remove your own hreflang tags from the theme when you start using Countries. They are typically in the theme's header template or in an HTML field.
If you use the same theme in several stores, and your own tags should only be used in stores without countries, you can wrap them in a condition. $webshop->getCountrySites() is empty when the store doesn't have at least two versions, which is exactly when Shoporama doesn't set hreflang itself:
<{if !$webshop->getCountrySites()}>
<link rel="alternate" hreflang="da-DK" href="https://dinshop.dk/" />
<link rel="alternate" hreflang="nb-NO" href="https://dinshop.no/" />
<link rel="alternate" hreflang="x-default" href="https://dinshop.dk/" />
<{/if}>
Links with an hreflang attribute are not rewritten to point inside the country. This also applies to the links in the theme's language switcher, which therefore need the attribute. How to build a language switcher with $webshop->getCountrySites() is described in Get your theme ready for Countries.
Separate stores on their own domains
If you instead have a separate store per country, for example dinshop.dk and dinshop.no, Shoporama doesn't set hreflang between them. The stores don't know each other's URLs, so you have to add the tags to the theme in both stores yourself. It only makes sense for pages that have the same URL in both stores, for example the front page or products with the same URL:
<{if $product}>
<link rel="alternate" hreflang="da-DK" href="https://dinshop.dk/<{$product->getUrl()}>" />
<link rel="alternate" hreflang="nb-NO" href="https://dinshop.no/<{$product->getUrl()}>" />
<link rel="alternate" hreflang="x-default" href="https://dinshop.dk/<{$product->getUrl()}>" />
<{/if}>

If a tag points to a URL that doesn't exist in the other store, Google ignores it, or you get an error in Google Search Console. If the products have different URLs in the two stores, it is safer to leave it out. If you want hreflang on all pages without maintaining it yourself, you can merge the stores into one store with Countries.
Tip
Always add an x-default tag that points to your primary language version. It tells Google which version to show to users when no specific language version fits. With Countries, Shoporama handles this and points it to the main country.
Frequently asked questions
Do I need to do anything to get hreflang for my countries?
No. When a country is active, Shoporama sets hreflang tags on all pages that exist in at least two languages. You only need to remove hreflang tags that you added to the theme yourself earlier.
Why do some of my products have no hreflang for my new country?
Because they haven't been translated yet. A product is included once it has a URL in the country's language. The automatic translation creates it when the name is translated, and a large store may take a few days to finish. Under Webshop → Translations → Products, you can filter by Translation missing.
How do I check that hreflang is set up correctly?
Open a page in the store, right-click, and choose to view the page source. Search for hreflang, and you will see the links to the other countries. If you can't see them, check that the country is active and that the page is translated. You can see errors that Google finds in Google Search Console.
Can Google see a country I haven't activated yet?
No. A country that is not active can only be seen by you when you are logged in to the admin, and its pages are marked noindex. The country is also not included in hreflang or in the robots.txt file's list of sitemaps until you activate it.
Need help? Contact us at support@shoporama.dk.
Related articles
Add multiple products to the cart at once
A guide to building an add-multiple-to-cart feature, for example on landing pages or wholesale pages.
Bulk update the cost price of multiple products
How to bulk edit the cost price (purchase price) of several products at once in the Shoporama admin, either with mass editing or a CSV import.
Age verification on products (15, 16, or 18 years)
How to set an age limit of 15, 16, or 18 years on products in Shoporama, so the customer's age is verified at payment with ePay, Flatpay, or Vipps...
Make your theme ready for multiple languages and countries
Step by step for developers: how to make a custom Shoporama theme work with Countries, with translated texts, the country's currency and number...
Translate your online store into other languages
How to translate your store when you sell in several countries: automatic translation, status per language, editing translations, translated URLs,...
robots.txt: control what search engines can crawl
Understand what robots.txt does in your Shoporama store, what the default content is, how to add your own rules, and when to use noindex instead.
Sell in multiple countries, languages, and currencies
Sell in other countries in your customers' own language and currency with Countries: add a country, set up its address, language, currency, and...
How to set noindex on a page, product, or category
How to set noindex on products, categories, pages, landing pages, and blog posts in Shoporama, so they are not shown in Google's search results.
SEO in Shoporama: a complete guide to the SEO features
A complete guide to the SEO features in Shoporama, from meta titles, meta descriptions, and the XML sitemap to keyword analysis, Google Shopping,...
Related features
Canonical URL
A canonical URL tells search engines which version of a page is the official one. Learn what it is, when to use it, and how it works in your online...
Hreflang
Hreflang tells Google that a page exists in several languages, so customers see their own language in search results. See how Shoporama sets it...
SEO in Shoporama – get found on Google
Built-in SEO in Shoporama: fast loading, control over titles and meta descriptions, dynamic tags, automatic 301 redirects, XML sitemap, noindex,...