On Shopify and Shopify Plus you usually don't write hreflang tags by hand. Shopify Markets adds them automatically, through content_for_header, for every market or language that has its own domain, subdomain or subfolder. You need custom hreflang tags in Liquid only when the automatic ones can't describe your setup, which mostly means one brand running separate Shopify stores on different domains.
This guide covers both cases. First, how the automatic tags work and how to check them. Then, when to turn them off, and a tested Liquid snippet for stores that need their own.
What do hreflang tags do?
Hreflang tags tell search engines which language and region each version of a page is for. Google uses them to send people to the right version. A product sold in the US, the UK and French-speaking Canada could carry these tags in the <head> of all three versions:
<link rel="alternate" hreflang="en-us" href="https://www.example.com/products/wool-sweater">
<link rel="alternate" hreflang="en-gb" href="https://www.example.com/en-gb/products/wool-sweater">
<link rel="alternate" hreflang="fr-ca" href="https://www.example.com/fr-ca/products/pull-en-laine">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/products/wool-sweater">
The French URL has a different handle, because Shopify lets you translate handles. That detail matters later, when we get to custom tags.
These are the rules from Google's hreflang documentation that matter most:
- Every version lists itself and all the others. If two pages don't point to each other, Google ignores the tags.
- A code is a language, optionally followed by a region. The language is ISO 639-1 (en, fr, de) and the region is ISO 3166-1 Alpha 2 (US, GB, CA). A region on its own is not valid, and codes outside those two standards aren't supported. Values are case-insensitive. The UK is
en-gb, noten-uk. - URLs must be fully qualified, including
https://. Alternates can sit on different domains. x-defaultis the fallback for visitors whose language or region matches none of your versions.- You can declare alternates in the HTML, in HTTP headers or in the sitemap. Google treats the three methods as equivalent.
Does Shopify add hreflang tags automatically?
Yes. When a market or language has its own URL, Shopify outputs hreflang tags on every page through the content_for_header object. Every theme renders that object in the <head> of layout/theme.liquid, so you need no app and no theme code. According to Shopify's developer documentation and the Help Center, these tags:
- use a region-qualified code for a country market (for example
en-usorfr-ca) and a language-only code for a broader market (for examplefr); - include an
x-defaulttag that points to your primary domain; - update by themselves when you add, remove or change a market's domains or languages;
- stay in sync with each page's canonical URL, and every localized URL is its own canonical;
- also appear in your sitemap, where each URL carries hreflang annotations.
Shopify's automatic market redirection skips known search engine crawlers, so Google can reach every market version. The one condition is a distinct URL. Markets that share one URL, with no language or region in it, have no alternates to point to, so they get no tags.
Which URL structure should you use?
Shopify supports subfolders, subdomains and separate domains for markets. It recommends subfolders for most stores, because they are the easiest to set up and share the authority of your main domain.
| Structure | Example | What to know |
|---|---|---|
| Subfolder | example.com/en-gb/, example.com/fr/ | Shopify creates these paths when you add a market or publish a language. Its recommendation for most stores. |
| Subdomain | ca.example.com | A separate host on your domain. Needs a DNS record per market. |
| Separate domain | example.ca | One domain per market. The most setup and the most to maintain. |
Plan the language and region map first
Write down which version each market gets before you create markets, because the map decides your URLs and your hreflang codes. A store selling in the US, the UK and Canada with French for Canada would look like this:
| Store version | Hreflang code | Target | URL |
|---|---|---|---|
| US English (primary) | en-us | United States | example.com/ |
| UK English | en-gb | United Kingdom | example.com/en-gb/ |
| Canadian French | fr-ca | Canada, French speakers | example.com/fr-ca/ |
| Fallback | x-default | Everyone else | example.com/ |
How do you check the hreflang tags on your store?
- Open a page in each market. Use the homepage, a collection and a product. View the page source and search for
hreflang. - Count the sets. You should find one set of alternates. Two sets, or the same code twice, means a theme or app adds its own tags on top of Shopify's.
- Check every URL in the set. Each one should return 200, not redirect, not carry a noindex tag, and match that page's canonical tag.
- Check the return links. Open one alternate and confirm that it lists the page you came from.
- Crawl the store. An SEO crawler with an hreflang report finds missing return links, wrong codes and redirected alternates across all pages at once.
- Use URL Inspection in Google Search Console to see how Google fetched a page. Google has deprecated the International Targeting report, so Search Console no longer has a dedicated hreflang report.
When do you still need custom hreflang tags?
Shopify's automatic tags cover most stores, including region-specific markets. Custom tags make sense in three situations:
| Situation | What to do |
|---|---|
| Separate Shopify stores for different countries, such as Shopify Plus expansion stores | Markets can't link pages across stores. Turn off the automatic tags in every store and add the Liquid snippet below. |
| Your theme or a translation app already outputs hreflang tags | Keep one source. Remove the theme or app tags, or turn off Shopify's. |
| A headless storefront, for example on Hydrogen | content_for_header is a Liquid object and doesn't run there, so your app has to output the tags or list them in its sitemap. |
The first case is the typical Shopify Plus one. A Plus organization can run up to ten stores on its contract at no extra cost, one main store and nine expansion stores, and Shopify lists international expansion as one of their uses.
If none of the three applies, leave the automatic tags on. Shopify warns that adding your own tags on top of its tags creates duplicate or conflicting annotations, which can hurt your search ranking.
Why not build tags for languages inside one store?
Because of translated handles. The same product can live at /products/wool-sweater in English and /fr-ca/products/pull-en-laine in French. A snippet that only swaps the language prefix points Google at the wrong URL. Shopify tells developers not to hardcode handles for this reason, and its automatic tags already follow each translated URL. Inside one store, leave hreflang to Shopify.
How do you turn off Shopify's automatic hreflang tags?
- In your Shopify admin, go to Online Store > Preferences.
- In the social sharing and SEO section, turn off Automatic hreflang tags.
- Click Save.
- Publish your own tags right away, so the store is never left without any.
To turn them back on, first remove every custom hreflang tag from your theme and make sure no app adds new ones. Then switch the setting on again and save.
How do you add dynamic hreflang tags with Liquid?
The snippet below links the same page across separate Shopify stores. It takes Liquid's canonical_url object and uses the replace filter to swap the current store's domain for each store's domain. That way it works on every page without hardcoded handles, and the same file works in every store.
It assumes three things:
- the stores use the same handles for the same products, collections and pages;
- each store has one language and no extra market subfolders;
- automatic hreflang tags are turned off in every store.
Step 1. Create snippets/hreflang-stores.liquid and replace the example domains and codes with yours:
{% doc %}
Outputs hreflang tags that link the same page across separate Shopify stores.
Put the same file in every store's theme, and only after turning off
Automatic hreflang tags in Online Store > Preferences.
@param {product} [product] - The current product, if any
{% enddoc %}
{%- liquid
assign show_hreflang = true
case request.page_type
when 'password', '404', 'search', 'cart', 'captcha'
assign show_hreflang = false
endcase
if request.page_type == 'product' and product.metafields.custom.hreflang_exclude.value == true
assign show_hreflang = false
endif
-%}
{%- if show_hreflang -%}
<link rel="alternate" hreflang="en-us" href="{{ canonical_url | replace: shop.domain, 'www.example.com' }}">
<link rel="alternate" hreflang="en-gb" href="{{ canonical_url | replace: shop.domain, 'www.example.co.uk' }}">
<link rel="alternate" hreflang="en-au" href="{{ canonical_url | replace: shop.domain, 'www.example.com.au' }}">
<link rel="alternate" hreflang="x-default" href="{{ canonical_url | replace: shop.domain, 'www.example.com' }}">
{%- endif -%}
Step 2. Render it in the <head> of layout/theme.liquid, after {{ content_for_header }}:
{% render 'hreflang-stores', product: product %}
Step 3. Put the same snippet, with the same list of stores, in the theme of every store. Each store then lists itself and all the others, which gives Google the return links it needs.
What the code does:
- Skips pages that shouldn't have alternates: password, 404, search, cart and captcha pages.
- Skips products that aren't sold everywhere. Create a true or false product metafield,
custom.hreflang_exclude, and set it to true on products that exist in only one store. No tag then points at a 404. - Starts from the canonical URL, so a product opened through a collection URL still points at the clean
/products/URL in the other stores.
Many older guides wrap the regional tags in {% if handle != blank %}. The homepage has no handle, so that version drops the alternates from the homepage, often the page you most want localized. The snippet above doesn't have that gap.
If your stores use translated handles, for example a German store with German URLs, a domain swap points at pages that don't exist. In that case store each product's alternate URLs in metafields and output those, or have a developer build the mapping.
What are the most common hreflang mistakes on Shopify?
- Two sources of tags. Shopify's automatic tags plus a set from an app or an old theme edit.
- Invalid codes.
en-ukinstead ofen-gb, a country code on its own, orbefor Belgium (it is the code for Belarusian). - Missing return links between stores. One store gets a new market and the other stores' lists are never updated.
- Alternates that redirect, return 404 or are noindexed, usually products that aren't sold in every market.
- Canonical tags that point at another market's URL. Each localized URL should be its own canonical.
- Relative URLs such as
/en-gb/products/...in custom tags. Google needs the full URL.
How often should you review hreflang?
Check the tags after every change to markets, domains, languages or the theme, and after installing a translation or SEO app. Crawl the whole store at least once a quarter. Hreflang problems rarely show up as errors anywhere; they show up as the wrong country version in search results.
Hreflang is one part of selling abroad. Our international ecommerce service covers Shopify Markets, translations, expansion stores and hreflang. If you want the rest of your technical SEO checked as well, start with our Shopify SEO checklist or our Shopify SEO service.
FAQ
Does Shopify add hreflang tags automatically?
Yes. Shopify Markets outputs hreflang tags through content_for_header for every market or language with its own domain, subdomain or subfolder. The tags include x-default, update when you change markets, and also appear in the sitemap.
How do I add hreflang tags in Shopify?
In a single store, give each market or language its own URL in Shopify Markets and Shopify adds the tags for you. For separate stores on different domains, turn off Automatic hreflang tags under Online Store > Preferences in each store and add a Liquid snippet like the one in this guide to every theme.
How do I change hreflang tags in Shopify?
The automatic tags follow your market settings. To change a code or URL, change the market's languages, domain or subfolder. To control the tags yourself, turn off the automatic ones first, so the store never outputs two sets.
Do I need an app for hreflang on Shopify?
Not for a single store using Shopify Markets. Some translation apps add their own tags. If yours does, keep either the app's tags or Shopify's, not both.
Is hreflang different on Shopify Plus?
The automatic tags come from Shopify Markets, so they work the same way on Plus. The difference is expansion stores: Plus can run separate stores per country, and Markets can't link pages across stores. That is where custom Liquid hreflang is still needed.
Which hreflang code should I use for the United Kingdom?
Use en-gb. The ISO 3166-1 Alpha 2 code for the United Kingdom is GB, and Google supports only codes from that standard, so en-uk is not a valid value.
Selling in more than one country?
We set up Shopify Markets, localised storefronts, hreflang, duties and international shipping so each market gets the right store.
The checklist we run before touching a client's code
Get it by email, plus a few short notes over the next two weeks: what we see most often on Shopify stores and what actually fixes it.
Want more of our posts in your Google results? Add Codersy as a preferred source.
Add Codersy on Google(opens in a new tab)
