If your Shopify store caters to multilingual or multi-regional audiences, implementing hreflang tags is a must. Hreflang tags are bits of code that indicate the language and regional targeting of a webpage. They guide search engines to serve the right version of your site to the right audience.
For example, if you have both an English version and a Spanish version of your Shopify store, hreflang tags will help Google know which one to show users based on their language settings or location. Store owners can add the tags to Shopify theme and this article will show you how to do it.
How to add hreflang tags in Shopify theme
To implement hreflang tags, you need to add them to the <head>
section of your Shopify theme. You can do this by editing the theme.liquid
file.
Start by going to your Shopify admin panel and navigating to the Online Store > Themes section. From there, click on Actions and select Edit Code. Open the theme.liquid
file, find the <head>
section, and insert the appropriate hreflang tags for each language or region.
Once you’ve added the tags, save the changes to update your site.
Here’s few examples of how they might look for different versions of a product page:
For an English product page, the tag would look like this:
<link rel="alternate" hreflang="en" href="https://your-store.myshopify.com/products/example-product" />
For a Spanish version of the same page, it would be:
<link rel="alternate" hreflang="es" href="https://es.your-store.myshopify.com/products/producto-de-ejemplo" />
And for a Spanish version targeting users in Mexico, it would look like this:
<link rel="alternate" hreflang="es-MX" href="https://es.your-store.myshopify.com/products
How to check the hreflang tags work after set up
Our recommendation tool for Shopify owners is Google Search Console. In Google Search Console, enter the URL of the page you want to check. Then, click “Inspect” to see the page’s details, including meta tags and hreflang attributes.
Another way is to look at the source code of your page. In the HTML, find the <link>
tags in the <head>
section—this is where you’ll spot the hreflang attribute.
To learn more about hreflang tags, you can explore Shopify’s multilingual store guides or refer to Google’s documentation. Both provide accurate advice and troubleshooting tips to help you get the most out of your setup.