
While hreflang tags are used to improve store switching, that's not only about it. They also help you mark different page alternatives and avoid duplicate content issues if you have multiple language variants. That's exactly what makes it one of the essential SEO factors.
Doesn't sound easy? Because it isn't, especially when it comes to the implementation. You have to add them through code or a sitemap. But only in case you don't have tools like
.So, in this guide, you'll learn how to add hreflang tags in the Magento admin directly. In fact, you don't even have to do it manually for some pages. The Magefan tool will cover them automatically.
Ready to start?
Configure Hreflang Tags
Before you start adding hreflang tags to Magento pages you need to fill out a few important settings. So, just navigate to Stores > Configuration > Magefan Extensions > Alternate Hreflang to start.
General settings
First of all, choose what Pages to enable the hreflang tags option on.
Then go through other available options:
- Enable Hreflang Tags For NOINDEX Pages — if you still want to communicate to search engines the relationship of different language variants even if one of them is not meant to be indexed.
Note: if you're testing the hreflang tags on the test website, enable this option, or the hreflang tags simply won't be added in your store (which is NOINDEX by default)
- Use Store Code In Default Store View Homepage Hreflang — if you want search crawlers to recognize the default store as a separate language or region variant (useful when you have multiple store views for different languages or countries).
- Use Trailing Slash For Homepage Hreflang — if you use trailing slash in your homepage URL and want to maintain consistency with your canonical URLs.
Locale settings
If you have a simple store set up, e.g. one store with multiple separate-language store views, you don't have to configure any of the locale options. But if the hierarchy in your store is more complicated, setting up hreflang tags in Magento becomes more complicated too.
We'll try to make things "clear" as much as possible. Let's consider several cases.
One website with store views that target language variants
e.g. You have a website with store views for American English, British English, Australian English, or French in France and French in Canada
In this case, you need to enable the Locale Depends On Region option to assign a certain store view to the region.
Additionally, you can also set the Custom Locale Code, if there simply is no corresponding locale in Stores > Configuration > General > Locale Options > Locale (e.g. en-FR, en-MY or en-SG). This field is optional.
Note: double-check the locale code you set to avoid hreflang mistakes and indexing issues.
One store view targets multiple regions (no separate URLs for each)
If you have a website with store views targeted at different regions but doesn't have unique URLs for each, you can set multiple locale codes for its hreflang. But first, you need to switch to that store view in the top right switcher to find that option.
Two or more websites with different language store views
In case you manage several websites, where each has multiple store views, and don't want the hreflang tags from each website to be shown on the other, set the Locale Group for each website.
Note: if you just have one website, set the Local Group to Default Group 1.
Finally, choose the language in the ets the hreflang="x-default" value for users whose browser settings don't match the available language or region.
Don't forget to Save the settings before you add hreflang tags to Magento pages.
Add Hreflag Tags to Magento Pages
The biggest drawback of the hreflang tags is that you have to add and edit them every time you make some changes to the store views. All of that through code.
But that's not a problem with the Magefan Hreflang Tags. Everything is managed from the backend.
So, let's see how.
Products and categegories
Important: if you have one website with multiple store views, products and categories will have the same IDs. In this case, the extension will automatically generate and update hreflang tags for your product and category pages. You don't have to do anything manually.
However, if your products and categories have different IDs (usually when they are added to different websites) you can add hreflang tags to them manually.
Just navigate to Catalog > Products and find a product you want to add hreflang tags to. Scroll down to the Alternative Store View Localizations section to set up your tags.
Start typing the product name in a corresponding field and choose the available options.
Magefan hreflang tags are bidirectional. It means that once you set them up on one store view, they are automatically filled out in the other store view.
e.g. if you are on the EN store view, specify just the other store view hreflang tags (in our case it's UK(Ukrainian)). Don't fill out both fields. The extension will automatically fill out the EN fields on the UK store view product page.
The process is entirely the same for the categories, But remember that you only need to fill out these fields in case your categories belong to two or more different websites.
CMS pages
When it comes to pages, you need to add hreflang tags to them just the way we did above. So, once again, navigate to Content > Elements > Pages and choose the page you want to add the hreflang tags to.
Then in the Alternate Store View Localizations section, start typing the page title i and choose the corresponding page from the dropdown.
Note: pay attention to the language of the page you're on.
Also, same as before, you don't need to go to the alternative page to set hreflang tags there. Our Hreflang Tags Extension 2 does it automatically.
Finally, check your hreflang tags on the frontend.
That's it, you're all set. Once you add hreflang tags to your pages or the extension does it for you, you won't need to edit anything unless you need to.
Any changes to the name of the page name or URL won't affect your hreflang tags since you add them through the ID. So they will be changed automatically.
However, don't forget about other pages. If you manage a blog, add hreflang tags to Magento blog pages too to make sure relevant language variants are displayed in search.