How To Use Hreflang For Magento 2

Ipad on Macbook Pro Beside Apple Magic Mouse

If you have a Magento 2 store that serves an international audience, you must consider implementing hreflang. Hreflang tags tell Google which version of your web pages to display to searchers based on their language or location. This can help improve your rankings among the right audience and drive more targeted traffic to your store.

Speed Up Your Magento Store by 300%

In Magento 2, there are a few ways to implement hreflang. In this guide, we will discuss the steps to follow to use hreflang in Magento 2 effectively.

1. Understand the Basics of Hreflang Tags

Hreflang tags are HTML attributes that tell search engines which version of a page to display to different audiences based on their location or language. When implemented correctly, hreflang can help improve your website’s localization and provide a better user experience for international visitors.

How Hreflang Works

Hreflang tags work by indicating to search engines the alternate versions of a page available in different languages or targeted to different regions. These tags help search engines understand which version of your page to serve to users based on their language and location.

When implemented correctly, hreflang can help your website appear in different search engines’ localized search results. This can increase the visibility of your website among relevant local audiences, leading to higher traffic and conversions.

2. Set Up Multiple Store Views

Before you can add hreflang tags to your Magento 2 store, you’ll need to set up multiple store views. Store views will allow you to create URLs for different language versions of your store, which will then be used in your hreflang tags.

To set up multiple store views in Magento 2, follow these steps:

  1. Go to Stores > Configuration > General > Web.
  2. Expand the section Add Store Code to URLs.
  3. Select Yes from the Add Store Code to URLs dropdown menu.
  4. Click on Save Config.

Once you have set up multiple store views, you can start adding hreflang tags to your web pages.

3. Add Hreflang Tags to Web Pages in Magento 2

To add hreflang tags to your web pages in Magento 2, you’ll need to edit your page’s source code. There are two ways to do this:

  1. Edit your page’s HTML source code directly by copying and pasting the hreflang tag.
  2. Use a Magento extension to generate hreflang tags automatically.

Edit Your Page’s HTML Source Code

Here’s how to add hreflang tags to your web page source code:

  1. Go to the page where you will add the hreflang tag.
  2. Open the page’s HTML source code by right-clicking and selecting View Page Source.
  3. Add the hreflang tag to the “ section of your page’s HTML source code.
  4. Replace the href attribute value with the URL of the version of your page that’s targeted to users in a specific geographic region or language. Be sure to add the ISO 639-1 language code and the ISO 3166-1 alpha-2 country code in the tag’s hreflang attribute value.

For example, if you’re creating an English language page that’s targeted to Canadian users, your hreflang tag should look like this:

Use a Magento Extension

If you’re not comfortable with editing your page’s HTML source code manually, there are Magento extensions that can help you generate hreflang tags automatically.

One such extension is the Hreflang SEO for Magento 2. This extension allows you to generate complete and accurate hreflang tags, including the correct country and language codes. The extension also features a user-friendly interface that makes it easy to add hreflang tags to your store’s web pages.

To use Hreflang SEO for Magento 2, simply follow these steps:

  1. Install the Hreflang SEO for Magento 2 extension from the Magento Marketplace or your preferred provider.
  2. Go to Stores > Configuration > Hreflang SEO.
  3. Enable the extension and select the storeviews on which you want to enable it.
  4. Select the URLs that you want to include in your hreflang tags.
  5. Save the configuration.

With Hreflang SEO for Magento 2, adding hreflang tags to your store’s web pages becomes much easier and more efficient.

4. Verify Your Hreflang Tags

After you have added hreflang tags to your store’s web pages, be sure to verify that they are working correctly. Google Search Console is a free tool that can help you verify your hreflang tags.

To verify your hreflang tags in Google Search Console, follow these steps:

  1. Log into your Google Search Console account.
  2. Go to the Search Appearance section and select HTML Improvements.
  3. Verify that Google has detected all of the hreflang tags you’ve added.
  4. Check for any errors or warnings and correct them as necessary.

Verifying your hreflang tags regularly helps ensure that they’re still working correctly and that there are no errors or issues that may affect your website’s rankings.

Conclusion

Using hreflang tags in Magento 2 is essential for any store that serves international audiences. By serving the right content to the right audience, you can improve your store’s visibility, drive targeted traffic, and increase conversions.

In this guide, we’ve covered how to set up multiple store views, add hreflang tags to web pages, and verify your tags’ correctness. By following these steps, you’ll be on your way to implementing hreflang tags the right way and reaching a broader audience.

Scroll to Top