Hreflang tags are recommendable elements to include in the HTML code of a website, as it helps inform search engines about the intended language of its content.
Hreflang tags provide search engine crawlers with the information they need to associate content written in different languages with each other, and they always appear in the HTML header. As an example, Hreflang tags could be used to make sure Spanish-speaking users in London are shown a translated version of the content on a website, and French-speaking users from Barcelona are shown this same content, but written in French.
What Is an Hreflang Tag?
An Hreflang tag (or rel="alternate" hreflang="x") is an HTML link element that informs search engines which language versions of a certain page the website owner knows of and supports. The basic structure looks like this:
link rel="alternate" href="http://example.com" hreflang="x" /
It’s important to note that ‘x’ in the hreflang attribute is not a placeholder, but rather stands for the actual language and dialect of your content.
The ‘href’ attribute contains the exact URL which should be associated with the language in question. The value for this attribute should never point to another website or subdomain.
What Does an Hreflang Tag Do?
When search engine crawlers find Hreflang tags on a website or webpage, they can use this data to adjust their indexing results when someone from a certain linguistic background searches for content on that site. This also provides a better result selection based on location and language preferences.
For example, a page with an Hreflang tag informing the search engine that there’s an English and Spanish version available of the same page, the search engine will then know to select the best language and location-based result for the user.
Using Hreflang Tags on a Website
Most websites feature content written in multiple languages. When this happens, creating the right Hreflang tags can be of great value and help the website appear higher in the search engine rankings.
As said before, the main purpose of an Hreflang tag is to inform search engine crawlers about the language versions and location-specific content of a website. That being said, every language version should be properly associated with its correct version. This means that when you create Hreflang tags, you need to create one for every language on the website.
Using the correct format is also essential. For example, when an Hreflang tag is declared, the language code should be specified and should be the same as the content language. Common language codes are en for English, es for Spanish, fr for French, and so on.
Also, be aware that any spelling mistakes, typos, wrong language codes, or improper URLs in either the language or href attributes will result in search engines ignoring them completely.
When it comes to regional codes, they are also recommended and should always be used whenever multiple regional variants of a certain language exist, such as es-ES (Spain), es-MX (Mexico) and es-AR (Argentina) for Spanish.
Another important thing to take into consideration is that if you are using HTML link elements, you can add multiple Hreflang tags and link to all the relevant language versions. Each language version should also self-reference itself. So – for example – the Spanish version must have a tag linking to the same page in Spanish, and not to the English version.
Most Popular Hreflang Attributes
Here is a list of the most popular Hreflang attributes you might want to use:
• x-default – This is used when you want to show a version to users from a country or region with an unknown language. It is usually the main version of the webpage.
• en-us – This is for audiences with US-English.
• en-gb – This is for audiences with UK-English.
• en-au – This is for audiences with Australia-English.
Become a Sales & Marketing Rainmaker
Learn valuable skills to win more customers, grow your business, and increase your profits.
• es-es – This is for audiences with Spain-Spanish.
• fr-fr – This is for audiences with France-French.
• fr-ca – This is for audiences with Canada-French.
• es-mx – This is for audiences with Mexico-Spanish.
• zh-hans – This is for audiences with Simplified Chinese.
• zh-hant – This is for audiences with Traditional Chinese.
Best Practices with Hreflang Tags
• Add an Hreflang tag to every page on the website.
• Ensure all URLs are valid and up-to-date.
• Make sure the content for each language variant is correctly associated with the hreflang tags.
• Be aware of any typos or mistakes when writing Hreflang tags.
• Include the x-default tag for pages which don’t have a specific language variant.
• Consider the 75-character limit.
• Refrain from using the same language code in more than one location.
• Always keep the language code and URL in the same order.
• Avoid using dynamic parameters when constructing URLs.
• If a page is available in more than one subdomain, use the language tag rather than the subdomain.
• Specify the language and region for every version of the content.
• Use the same language tag for all language variants.
• Don’t redirect users if the content language is different.
• Tag alternate languages with a link element.
• Test the Hreflang setup before finalising it.