Hreflang tags are a powerful way to tell Google which international version of your site is most relevant to a user, based on their language and location.
As well as improving your user experience (because it helps users land on the most relevant version of your site), hreflang tags are a great way to manage duplicate content issues caused by international websites.
How do I know if I need hreflang?
Google recommends using hreflang if you have:
Similar regional variations of the same site in the same language (eg. currency variations for GBP and USD)
The same content in different languages
Writing hreflang: three essential elements
All hreflang tags contain three elements:
The rel=”alternate” attribute
A language code on its own, or a language code plus a country code
One URL for the most appropriate alternative for the specified language and country
For example, this hreflang tag will notify Google about an alternative version of the page suitable for English-speaking users in Great Britain (en-gb).
It can be a good idea to have generic language sites for each of your main languages, to account for the vast majority of your users where this isn’t a specific language + country available. A language code on its own will be used as the default where there isn’t a relevant language + country code.
The following tags would account for all English and German-speaking users, no matter which country they are in:
You can add hreflang tags to your sitemaps, in the HTTP response headers, or on the page itself.
In your sitemaps
The best place to add hreflang is in your sitemap as including them in the headers or on the page adds weight to every single page request.
The following example will inform Google about the English version from the German version of the website:
This method would need to be repeated in full for every page on the site and for all the international websites.
In your headers and HTML
Hreflang tags can also be added to the HTTP header:
Link: <http://www.example.com/english/>; rel=”alternate”; hreflang=”en”
Link: <http://www.example.com/deutsch/>; rel=”alternate”; hreflang=”de”
Or in the <head> tag in the HTML:
<link rel=”alternate” hreflang=”en” href=”http://www.example.com/english/” />
<link rel=”alternate” hreflang=”de” href=”http://www.example.com/deutsch/” />
What can go wrong?
Google will ignore your hreflang tag in the following situations:
Language + country code the wrong way round:
gb-en instead of en-gb, for example.
Using the country code on its own, without a language code:
Google does not take a default language from the country code. When including a country code, always precede it with the language code.
Using continental region codes:
en-eu instead of en-gb, for example.
Canonicalising a page with hreflang:
This may mean the page cannot be indexed and will not be returned in search results.
If you have specified two different URLs as the alternative for the same language + country then they will both be ignored.
Broken/disallowed hreflang URLs:
If the URLs you include in your hreflang tags are broken or disallowed in robots.txt, then they will be ignored.
Every time you list a set of hreflang alternative URLs for a page, you must include the URL and language + country code of the page itself in the set of hreflang tags.
Testing hreflang with DeepCrawl - useful reports
Hreflang can be very difficult to implement correctly and equally difficult to test. DeepCrawl includes three powerful reports to help you keep track of your tags and identify any hreflang issues.
1. Pages with hreflang
All pages found with at least one hreflang tags found in the sitemaps, header or page tags.
In your DeepCrawl report, go to: Validation > Pages with hreflang Tags
The report shows a detailed view of each page’s alternative URLs for every language/country variation used on the site. This view will also show you if a tag has been implemented inconsistently – there should be no gaps in this table:
2. Pages without hreflang
You can quickly identify all pages missing hreflang tags within the sitemaps, header, or page tags.
Go to: Validation > Pages without hreflang Tags
3. Pages with inconsistent hreflang
If there is more than one alternative URL specified for a country + language combination, they will be flagged as inconsistent in this report.
Go to:Validation > Inconsistent hreflang Tags
Log in to your account now to view pages with, without or with inconsistent hreflang tags on your site or check out our other blog posts.