Hreflang: Internationalization and web localization

When the same website is available in different languages, it is essential that search engines are able to identify the correct version based on the users' country of location. If the technical configuration of the website is not correct, it may happen that a user located in Portugal may see search results of the website in a different country version despite having a version for this country. 

For this reason, hreflangs arise with the idea of avoiding these conflicts and to avoid errors in the internationalization of the web.


How can the attribute hreflang in international SEO?

Let's assume you have a Spanish website that you have just translated into English and German. "I've already gone to the trouble of adapting the website to the target audience. Now, how do I get Google to index the German page in Germany and not the English one?". The answer is Hreflang.

The main function of hreflang is to provide information to the search engines so that they offer, from the options on that page, the version that best suits the user depending on your language and geographic location.

This is an html code tag that is placed in the head and must appear in all urls of the domain.


Attribute advantages hreflang

When applying the attribute hreflang to the pages of our website, we inform Google which content we have created for that particular countryand that other non-localized versions of the site do not rank above it.

Therefore, this attribute is practically necessary when working with multiregional or multilingual sites. But it is also particularly useful when working with variations in currency, shippingseasonality and/or culture.

By implementing it, the user experience and user satisfaction are significantly improved, which translates into in increased web traffic. In addition, it prevents Google from considering duplicate content and penalizing organic positioning.

It's all advantages!


Correct syntax of hreflang

When it comes to implementing the attribute, there are three possible options:

Implementation hreflang links in the :

This is the most common option. It is placed inside the head section, and a link tag of type link for each language, containing the language code and the URL of the corresponding version:

<link rel="alternate" hreflang="LanguageCountry" href="Destination URL" />

In the case of a page with English, French and German versions, the code would look like this:

Hreflang HTML code

In the event that content is generated for countries that have the same language but have regional differences, as in the case of a website with a British version and an American version, the country code must be indicated in addition to the language code.

Hreflang HTML -regional code


Implementation hreflang in HTTP header:

It is used in non-HTML files, such as PDF files, to indicate that a foreign language version of the URL exists.

Link: <Spanish URL>; rel="alternate"; hreflang="is“,

<English URL>; rel="alternate"; hreflang="at“,

<German URL>; rel="alternate"; hreflang="from


3. Implementation hreflang in XML sitemap:

It is used as a substitute for markup language. An example of a sitemap.xml that includes these attributes would be as follows:

Hreflang XML code


Other technical aspects of hreflang

X-defaultThe default version

For countries that have not been taken into account in the localization, it is always a good idea to have a default version to direct them to. To do this, the following line should be added to the link type links in the head:

<link rel="alternate" hreflang="x-default" href="destination URL" href="destination URL" />


Hreflang y canonical

The attribute hreflang and the attribute rel="canonical" can be used together. What's more, it is It is highly recommended that they be used together and, on each page, the rel="canonical" point to itself. Otherwise, it would spoil the international implementation.

That is to say, in a website translated into Spanish and English, in the Spanish version we should insert the following code:

Hreflang + canonical code - EN

However, when switching to the English version, the canonical tag in the code should point to itself:

Hreflang + canonical code - EN


Useful tools for hreflang

The Aleyda Solis tag generator gives you the option to generate the XML code to add in your sitemap or link tags of type link to include in the of the page:


To use this tool, you must upload to the Media Flow website a CSV file containing a column for each language and the relevant URLs.

This is a very simple and intuitive tag validator. By entering the URL of the page, it will perform an analysis of the implementation and detect bugs, if any.

hreflang validator - Flang


In Geotelecom, we help you to improve your international web positioning with our service "Internationalization SEO". We hope we have been helpful!

How useful did you find this content?

Click on a star to rate!

Average score 5 / Counting of votes: 2

So far, no votes. Be the first to rate this content.


Subscribe to our newsletter!

Don't worry, we won't fill your inbox with dozens of emails. Every month we compile the latest news from the digital marketing sector and send them to you. 

    geotelecom white.png
    logos partner4.png
    european union logo small2.png
    text unioneuropea english.png
    texto innovation english.png