Frequently Asked Questions
Why should I use hreflang in Magento 2?
If you have an international website with multiple languages, you need to inform Google bots about what pages have the same content but in different languages. Using the hreflang attribute for your Magento 2 will help Google to rank your site correctly and offer translation suggestions.
Hreflang is an HTML meta element that looks like this:
<link rel="alternate" href="http://example.com/en-gb/" hreflang="en-gb"/>
and used to mark duplicate content in another language.
There are three main advantages of using the hreflang attribute:
The tag makes it easier for Google bots to understand what content is preferable for a specific language search. Thus, your site will be ranked better in different markets.
When you translate the same content to different languages and place it on different URLs, Google can recognize it as duplicated content and hide these pages from search results or rank them at lower positions. The Hreflang tag allows bots to understand the difference between pages.
As soon as the hreflang attribute helps to show the most relevant search results, users will immediately go to the page with their native language and currency without any additional actions and redirects. This will decrease the bounce rate and improve customer satisfaction.
There are 3 ways you can set the hreflang attribute:
In this article, we will show you how to set the hreflang attribute in XML Sitemap. Why sitemap?
1. To configure hreflang tags, go to Stores > Configuration > Amasty extensions > XML Google Sitemap and open the Hreflang URLs section.
2. In the Hreflang URLs Scope field, chooseWebsite or Global to work with one specific website or between the websites.
3. From the Language Code dropdown, select the needed language.
4. In the Country Code field, choose for what region you created the content.
5. In the X-default field, specify which store should be tagged as default.
6. For multi-stores, you can connect CMS pages by ID, Hreflang UUID, and Hreflang URL Key. For this, set the needed option in the Multi-Stores CMS Pages Relation field.
7. Save the changes.
When creating a new sitemap, you can add hreflang tags to your Magento 2 product, category, and CMS pages. For this, navigate to Content > SEO Toolkit > XML Google Sitemaps and click Add Sitemap:
The Magento 2 XML Google Sitemap allows you to use advanced settings for XML sitemaps and includes or exclude last modified pages, out of stock products, specific product types, add category images to the map, or remove unnecessary CMS pages. Also, you can manage your current cron tasks and see their status.