This is Novos

Home / Blog / Magento /

How to implement hreflang in Magento 2

Sam Hurley from NovosSam Hurley in Magento, SEO

7th February, 2020

How to implement hreflang in Magento 2

If your eCommerce site operates across multiple markets then you will need hreflang tags and you will need to ensure they are set up correctly.


If your site does not have hreflang tags set up or if they are set up incorrectly then it will result in a negative impact on your SEO and user experience. For example, individual store views for different locations may start to compete against one another in the search results (for example a US jeans page vs a UK jeans page). 


This can result in lower rankings and/or a poor experience for customers that land on your website. E.g. a UK customer landing on a USA page that shows US dollars and your US stock. This would also impact negatively on your engagement and conversion metrics. 


Options to Implement Hreflang

Hreflang can be implemented via several different methods in Magento 2:


  • Hreflang sitemaps
  • HTTP header response
  • HTML code


For this example, we’re going to focus on the hreflang sitemap. 


eCommerce sites are naturally much larger than normal websites, coupled with the fact the sites are built dynamically, which can easily start to cause headaches for Google. We always recommend eCommerce websites to implement hreflang in the sitemap, for the following reasons:


  • Sitemaps are generated dynamically 
  • The sitemaps are separate from the onsite code so will never be affected by a code release or dev error 
  • HTML codes rely on page load which has varying experience and can cause bloat 
  • It’s easier to manage and spot errors in the sitemap
  • There’s less of an issue with ‘non-referring’ pages that are missing a hreflang back to a referer 


This is particularly important for websites over 10k URLs. It’s important to select ONLY ONE of the above implementation routes in Magento 2. If you implement 2 and they contradict each other then Google will just ignore them with no error or alert.

"For eCommerce websites, we recommend implementing hreflang in the sitemap"

How to implement Hreflang in Magento 2?


    1. Download & install Amasty
    2. Log into Magento back end
    3. Navigate to Content > Amaty XML Google Sitemap then click XML Google Sitemap
    4. Next click ‘add sitemap’
    5. Name the sitemap with ‘hreflang’ so you know it’s not the main sitemap or an image sitemap e.g. /sitemaps/hreflang-sitemap.xml is completely fine
    6. Select your main market as the store, it doesn’t matter as the 1 sitemap will generate sitewide referring tags
    7. On the left-hand side navigate to a product and select ‘yes’, once you do this you will get additional options including ‘add hreflang tags’ which you set to yes

  1. Exclude images from this sitemap
  2. Keep out of stock products in this sitemap to avoid referencing errors if a product is out of stock in one market but not the other
  3. Next move to ‘categories’ then ‘pages’ with the same set up as steps 8 and 9
  4. Once done, click save
  5. Now submit this sitemap to Google through your Google search console account here
  6. Add this URLs to your robots.txt. Find out how with our guide to editing the robots.txt on magento 2

Note: a sitemap has a limit of 50k, if yours exceeds this amount then Amasty will automatically create an ‘index’ URL which is just a ‘contents’ page of all of the hreflang sitemaps you’ve created. Once you have this ‘index’ you can submit that 1 URL to Google as well as the ‘children sitemaps’ 




Hreflangs are essential for any eCommerce store that wants to trade across markets and gather relevant high-quality traffic. The Amasty plugin is the best option we have found to generate these tags without having to worry about additional dev resources.

Sam Hurley from Novos
Article by Sam Hurley
Sam is the Co-founder and Chief Strategy Officer of NOVOS. With nearly a decade-long experience in organic search, Sam has helped many eCom brands grow. His area of expertise includes SEO strategy, Magento, international SEO, and headless CMS with Javascript.

Get in touch

We're eCommerce specialists for a reason, get in touch with us today and find out more.

I'd love to be sent your monthly newsletter for eCom tips, news and advice
Cyber warning: NOVOS ( is not affiliated with any other third party company and will never contact you other than from a legitimate email.