Last active
December 15, 2016 06:45
-
-
Save blueprintmrk/809096eac7a41ff429f3 to your computer and use it in GitHub Desktop.
examplesite.com/es-419 hreflang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
1. 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/”> | |
2. 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” | |
3. 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 2015, 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment