Hreflang was introduced by Google in 2011 to help site owners serve the correct language or country-based language variation to users around the globe. All country-based Google search engines, as well as Yandex, support hreflang. If you’re targeting Bing, you’ll have to use language meta tags instead.
Google gives us some examples where rel=”alternate” hreflang=”x” is recommended:
- The entire website is fully translated in another language, i.e. one version in Spanish – http://www.examplesite.com/es and one version in German http://www.examplesite.com/de.
- You have regional variations within a single language, i.e. one version in Spanish for users in Mexico – http://www.examplesite.com/es-419-mx and one version in Spanish for users in Spain – http://www.examplesite.com/es-es.
- Your site is partially translated with the main content being in a single language i.e. sites with translated site temple only (navigation menu/footer). This is very common on user-generated sites like forums and discussion boards.
So, how does an SEO implement hreflang correctly? Google gives us three methods:
-
- HTML Link Element In Header
In the HTML <head> section, add a link element pointing to the language or language/country version of that webpage:
<link rel=”alternate” hreflang=”es” href=”http://www.examplesite.com/es/”>
Note: If your site is targeting multiple languages or language/region variations, the hreflang tag should include each variation. This is crucial so that search engines understand the relationship between each URL variation and serves the right content to users.
<link rel=”alternate” hreflang=”es” href=”http://www.examplesite.com/es/”>
<link rel=”alternate” hreflang=”de” href=”http://www.examplesite.com/de/”>
-
- HTTP Header For Non-HTML Files Like PDFs
Indicate a different language or language/country version of a URL in the HTTP Header:
Link: <http://www.examplesite.com/es/>; rel=”alternate”; hreflang=”es”
Note: To specify multiple hreflang values in a Link HTTP header, separate the values with commas like so:
Link: <http://www.examplesite.com/es/>; rel=”alternate”; hreflang=”es”, <http://www.examplesite.com/de/”>; rel=”alternate”; hreflang=”de”
- XML Sitemap
Instead of using markup, you can submit language or language/country version information in an XML sitemap.
The example sitemap below is from Search Console Help forum and describes a site that has pages equivalent to the English version (www.example.com/english/) targeting worldwide German-speaking (http://www.example.com/deutsch/) users and German-speaking users in Switzerland (http://www.example.com/schweiz-deutsch/). This would require you to have one XML sitemap for the entire website.
There’s A Few Things You Should Be Aware Of:
- The country is optional, the language is not. Hreflang works independent of the country. You can specify a language version of your site or you can specify language & country. For example, using the HTML link header method – this is a site that has a default version for Spanish language users worldwide, but also offers a version of the URL for Spanish language users in Mexico:
<link rel=”alternate” hreflang=”es” href=”http://www.examplesite.com/es/”>
<link rel=”alternate” hreflang=”es-419-mx” href=”http://www.examplesite.com/es-mx/”>
- Search engines support ISO 639-1 for language codes and ISO 3166-1 Alpha 2 for the region. For language script variations, the script is derived from the country itself. For example, the language code for Portuguese (Brazil) is: pt-BR and for Portuguese (Portugal) it is: pt-PT.
The hreflang tags in this case would be: pt-BR-br and pt-PT-pt. Search Console Help refers you to ISO 15924 for language scripts but the explanation is not that clear.
- Although not listed in Search Console, Google also seems to support IETF language tags as supported language values. I found this by reviewing the hreflang tags used on Google properties like Android.com. For example, the language code for Spanish (Latin America & Caribbean) is es-419. 419 is the regional code used by the United Nations and one of the components of IETF language values.
- You should only use one out of the three methods to implement hreflang. If you’re using more than one method, this creates redundancy.
- One method is not better than the other but Google does recommend the HTTP header method for non-html files.
- X-default hreflang is a tag you can use to identify a page that doesn’t target a specific language or region. This is most commonly used on country-selector homepages.
The Android site has a version of their website that doesn’t target a specific language or region and therefore utilizes x-default hreflang site-wide.
In 2014, Google Search Console (then Google Webmaster Tools) added a feature to identify issues with the rel-hreflang-implementation on your site.
The Most Common Mistakes Site Owners Make When Implementing Language/Country Annotations Are The Following:
- No Return Tags – If page A links to page B, page B must link back to page A. Annotations must be confirmed from the pages they are pointing to. Google gives site owners insights as to where the error was detected and where the return link should be.
- Invalid Country Or Language Codes – In the example below, the site uses JP to specify Japanese, however the correct ISO 639-1 code is actually JA for Japanese. Google also provides examples on how to fix this in your site’s Google Search Console dashboard.
So What Happens If I Implement Hreflang Incorrectly?
If you implement hreflang incorrectly, search engines will not be able to interpret the tag and will ignore it. Don’t believe me? Check out what Google Webmaster Trends Analyst Gary Illyes had to say…
So at this point you’re probably thinking… “Zetus Lupetus! My site has thousands of pages in over a dozen languages, and my URLs structures vary from country to country. This seems like a lot of work. What’s the big deal with hreflang anyway?”
And you’re probably right. Depending on the website, hreflang can get very complicated…very fast. But keep in mind that the language of your users and their location are two of the biggest influencing factors in Google’s search algorithm. Besides delivering the best user experience to your site visitors globally, recently at SMX Advanced 2015, Cyrus Shepard at SearchMetrics identified a correlation between organic rankings and the use of properly implemented hreflang tags.
Below are some tools for hreflang tag implementation. Please note that these tools still require manual work. For example, the hreflang tag generator requires you to input every single url and language/country variation. If you’re going with the sitemap, remember that you’ll need one XML sitemap for the entire website. These tools may not be feasible depending on the extent of your site and resources.
Questions? We can help.