If you are running a website that aims at multiple countries and languages, you need to use hreflang. 

It is a tag that commands Google which version of your website to show users, depending on their location and preferred language.

In this guide, we will discuss what hreflang is, how to set it up, and the benefits of using it.

What is Hreflang?

Hreflang is an HTML tag that helps browsers and search engines understand the language of a website’s content and determine which version of a website to serve to a user in a given location. It is essential because it helps serve users in a particular area with the most relevant website version.

The hreflang tag is in the head section of a web page and has two parts: the “href” attribute, which contains a URL that points to a language file; and the “lang” attribute, which includes a two-letter code that indicates the language of the website’s content.

The hreflang attribute only indicates relationships between web pages in different languages or regions. It does not indicate relationships between web pages in the same language or region.

When a browser or search engine encounters a web page with a href lang tag, it can use the information in the tag to determine the correct language version of the page to display. It is beneficial for websites that are available in multiple languages, as it ensures that users always see the correct language version of the site.

Href lang tags are also helpful for SEO, as they can help Google index a website’s content correctly. It is significant for websites that target multiple languages as it ensures the right content to the right audience.

What does Hreflang look like?

The href lang attribute specifies the language of the linked document.

<a href=”http://example.com” hreflang=”en”>English</a>

<a href=”http://example.com” hreflang=”de”>German</a>

<a href=”http://example.com” hreflang=”fr”>French</a>

If the href lang attribute is not specified, the browser will assume that the linked document is in the same language as the current document.

The value of hreflang attributes must be valid language codes.

illustration of hreflang marketing tag icon 
 

Why is hreflang important for SEO?

Hreflang is essential for SEO because it helps Google determine which version of a piece of content to show users based on their location and preferred language. Hreflang is also vital for ensuring the direction of users to the most relevant version of a piece of content, which can improve the user experience and reduce bounce rates.

The benefits of hreflang are many and varied, but some of the most notable include increased international traffic, improved SEO rankings, and higher conversion rates. 

In addition, hreflang can also help improve the user experience on your website by providing users with content relevant to their location.

Some of the benefits of hreflang for international traffic include:

  • Increased traffic from new markets

By using hreflang tags, you can make your website more visible to Google in new markets, leading to an increase in traffic.

  • Improved SEO rankings

Hreflang tags can help to improve your website’s SEO rankings by making it easier for Google to index your content.

  • Higher conversion rates

By providing users with relevant content, hreflang can help to improve conversion rates on your website. Some of the benefits of hreflang for the user experience include:

  • Improved usability

Hreflang tags can make it easier for users to find the content they are looking for on your website.

  • Increased engagement

By providing users with relevant content, hreflang can help to increase engagement on your website.

  • Improved conversions

By making the content more accessible for users to find what they are looking for, hreflang can help to improve conversion rates on your website.

Who supports hreflang?

illustration of web search engine for who supports hreflang

Search engines including Google, Yandex, Baidu, and Bing support hreflang.

For search engines to serve the correct content to users in different languages and locales, it is crucial that web admins correctly implement hreflang annotations on their websites.

The hreflang attribute tells search engines what language and locale the target page is.

In addition to hreflang, webmasters should also consider other factors such as region targeting in Google Search Console, the use of ccTLDs or gTLDs with country code, and the rel=”alternate” link element.

Do you need to use hreflang?

Hreflang is an integral part of international SEO. It helps Google understand which other language versions of your content are relevant for which location and ensures that users in different countries see the correct version of your site.

Without hreflang, Google may deliver the wrong version of your site to users in different countries, leading to a poor user experience.

Hreflang is especially important if you have multiple versions of your site for different countries or languages.

For example, if you have a website that is available in both English and French, but you do not want users in France to see the English version of your site, you would not use the hreflang attribute. Instead, you would use a redirect to send users from the English version of your site to the French version.

Similarly, if you have a website that is available in both English and French, but you do not want users in the United States to see the French version of your site, you would not use the hreflang attribute. Instead, you would use a redirect to send users from the French version of your site to the English version.

How to use hreflang attributes

businessman pointing on question mark of a word how

When setting up your international website, you will need to use hreflang attributes to ensure that your site is accessible to users in all countries. It indicates the relationship between the current web page and another page written differently.

Implementing hreflang using HTML

implementing hreflang using html

HTML offers a mechanism through the hreflang attribute, by which you can specify the language of a given web page. It is helpful in situations where your website contains content in multiple languages, and you want to ensure that users directly to the correct language version of a web page.

The href lang attribute takes the form of HTML tags attribute, and can be used in the <head> section of a document, like so:<link rel=”alternate” hreflang=”x-default” href=”http://example.com/en-us/dictionary/” />

In this case, the hreflang attribute specifies that the web page is the default page for visitors who do not select a language preference.

The href link attribute identifies the location of the page. You can also use hreflang to specify alternate versions of a page in other languages:<link rel=”alternate” hreflang=”en” href=”http://example.com/en-us/dictionary/” />

<link rel=”alternate” hreflang=”es” href=”http://example.com/es-mx/diccionario/” />

In this case, the hreflang attribute is specifying that there are alternate versions of the page in English and Spanish, respectively.

Note that the hreflang attribute value is always a two-letter language code, followed by a two-letter region code (if applicable).

Give some country code examples.

Implementing Hreflang using HTTP

There are a few different ways to implement hreflang using HTTP headers. One way is to use the Link header, which looks like this:

Link: ; rel=”alternate”; hreflang=”en-US”

You can also add the hreflang attribute to the <link> element:

<link rel=”alternate” hreflang=”en-US” href=”http://example.com/en-us” />

Finally, you can use the HTTP header X-Default:

X-Default: http://example.com/en-us

It will redirect users to the specified URL if they don’t match any of the other hreflang tags.

Implementing Hreflang using Sitemap

implementing hreflang using sitemap

A sitemap is an important file for a website as it tells search engines about your web pages and the frequency of their updates.

You can use Sitemap to implement hreflang in two ways: by using links in the Sitemap or by using <loc> tags in the Sitemap.-If you want to use links in the Sitemap, you need to add the following code in the <head> section of your page:<link rel=” alternate” hreflang=”x” href=”http://example.com/page-x”></link>

It will tell the search engine that there is an alternate version of this page in another language, and the language code will replace the x in hreflang=”x”. -If you want to use <loc> tags in the Sitemap, you need to add the following code in the <head> section of your Sitemap:<loc>http://example.com/page-x/</loc>

It will tell Google that there is a page in another language at this location, and the language code will replace the x in hreflang=”x”. You can choose whichever method you prefer as both methods are equally effective.

Hreflang Implementation Rules

When it comes to adding internationalization to your website, the sky’s the limit in terms of what you can do. However, there are things to keep in mind when using hreflang tags on your site.

Return links

As part of hreflang rules, return links are put in place to ensure that Google recognizes when a page serves multiple languages. It is significant for international websites that want to ensure they are getting traffic from all over the world.

Return links help to show search engines which language version of a page they should index for each region.

Without return links, Google might index the wrong page version, resulting in lost organic search traffic and revenue.

Self-Referencing

When using hreflang rules, it is important to do Self-Referencing. It means that you should always include a link to the page in the list of alternate versions. For example, if you have a page in English and French, your hreflang tags would look like this:<link rel=” alternate” hreflang=” en” href=”http://example.com/en/” />

<link rel=”alternate” hreflang=”fr” href=”http://example.com/fr/” />

<link rel=”alternate” hreflang=”x-default” href=”http://example.com/” />

In this example, the x-default hreflang tag is for Self-Referencing. It ensures that if a user arrives on the page from a country not specified in the other hreflang tags, they will still be able to see the correct version of the page.

To properly do Self-Referencing in hreflang rules, you’ll need to take a few steps:

  1. Make sure each of your web pages has a unique URL.
  2. Add the self-referencing hreflang tag to each page, pointing to itself.
  3. Include the self-referencing hreflang tag on your site’s Sitemap.
  4. Submit your Sitemap to Google.

By following these steps, you can ensure that Google will properly do Self-Referencing on the hreflang rules when indexing all the pages of your website. It will help Google understand your website’s content better and improve its ranking in search results.

X-default

If you’re using hreflang on your website, you may wonder what the “x-default” rule is and how it works.

The x-default rule specifies a page that website should show to users who don’t match any of the other rules. It is helpful if you have a multilingual site and want to ensure that users who don’t speak the same language you’ve specified will still be able to see a page in their language.

To use the x-default rule, simply add it to your hreflang tags like this:<link rel=”alternate” hreflang=”x-default” href=”http://example.com/“>

It will tell search engines that they should show the page at http://example.com/ to users who don’t match any of the other hreflang rules.

Keep in mind that the x-default rule is only helpful if there are no other rules that match the user’s language. So, if you have a hreflang tag for English (en) and another for French (fr) but no x-default rule, then users who speak neither English nor French will not see any page.

If you want to ensure that all users can see a page in their language, even if you don’t have a hreflang tag for that language, then you’ll need to add an x-default rule.

Tools For Implementing Hreflang

Assuming you have a website in multiple languages, the hreflang attribute tells search engines which version of a page they should return to users based on their country and language codes. It is significant for international SEO, where failing to implement hreflang properly can result in ranking issues.

Implementing hreflang tags can be tricky, and a few tools are available to make the process easier. 

hreflang tag generator

An hreflang tag generator is a tool that helps you automatically generate codes that implement hreflang tags on your website. It can be helpful if you have a lot of content in different languages and want to ensure the correct optimization of your website for search engines. 

To use the hreflang tag generator:

  1. Enter the page’s URL that you want to implement hreflang on.
  2. Select the language and region that you want to target.
  3. Choose whether you want to add alternate URLs or not.
  4. Click on the “Generate Tags” button.
  5. Copy the generated tags and paste them into your page’s <head> section.
  6. Save your changes and publish your page.

hreflang XML sitemap generator

The hreflang XML sitemap generator is a tool that generates an XML sitemap that contains information about the hreflang tags on your website. You can submit this sitemap to Google and other search engines to help them understand the relationships between the different versions of your content.

Here’s how to use it:

  1. Enter your website URL into the hreflang XML sitemap generator tool and click “Start.”
  2. Select the language and region for your website from the drop-down menus.
  3. Click “Generate.”
  4. Copy and paste the generated code into your website’s code.
  5. Save your changes and re-upload your website.

Now, when someone visits your website from a different region or language, they will be automatically redirected to the correct version of your site. It is a quick and easy way to ensure that everyone who visits your website can find the content they’re looking for, no matter where they’re from.

Conclusion

Hreflang is a great way to improve your website’s SEO for the multilingual target audience. It helps search engines understand which language your website is written in and signals that your content is relevant to users who speak that language.

When used correctly, hreflang can be a powerful tool to help improve a website’s international SEO. However, it is essential to note that hreflang is only one of many other SEO factors that Google use in determining how to rank your website and which content to serve users in different languages and locales.