We bring information of interest to all those who e-commerces and websites that have chosen to segment their market by language or region.
Table of Contents
ToggleAs we already mentioned in the post "5 keys to adapt your website to a foreign country"The choice of the domain name, the correct translation of the contents, the localization and cultural adaptation, as well as the web usability (UX), are critical aspects that will determine the success and popularity of your website in the international market.
However, once you have polished all these aspects, if you want to carry out a good international or local SEO strategyattribute hreflang is of special interest to you.
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.
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 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="Language–Country" href="Destination URL" />
In the case of a page with English, French and German versions, the code would look like this:
In the event that content is generated for countries that have the same language but have regional differences, as is 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.
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:
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:
However, when switching to the English version, the canonical tag in the code should point to itself:
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:
- Generator of hreflang for XML sitemap
To use this tool, you must upload a CSV file containing a column for each language and the relevant URLs to the Media Flow website.
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.