Hreflang
Hreflang is a declaration with which you tell search engines which pages contain the same offering for other languages or countries. Google can then show users the fitting language version and does not have to treat the versions as duplicates.
What hreflang does
Hreflang is not a ranking factor. The hint does not change how well a page ranks, but which address Google shows in the results when several equivalent versions exist: a user with a German language setting gets the German page, one with English gets the English page. Typical cases are a website in several languages and pages for the same language in several countries, for example German for Germany and Austria.
Three ways to specify hreflang
| Way | Where | Suited for |
|---|---|---|
| Link tags in the head of the page | <head> of every page | most websites, few languages |
| XML sitemap | Entries with xhtml:link in the sitemap | many pages or many languages, maintainable in one place |
| HTTP header | Header of the response | Files without HTML, such as PDFs |
Choose one way and stick to it. Using all three together brings no benefit and easily leads to contradictions.
<!-- hreflang: link language and country versions -->
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="en" href="https://example.com/en/">
<link rel="alternate" hreflang="es" href="https://example.com/es/">
<link rel="alternate" hreflang="x-default" href="https://example.com/en/">
Rules
- Every version names all versions, including itself. The list is the same on all pages of the group.
- The references are reciprocal. If the German page points to the English one, the English one has to point back to the German one. Without the return reference Google ignores the hint.
- Addresses are complete, with protocol and domain.
- x-default marks the page that should apply to all other users, such as a language selection or the English version.
- The codes: language per ISO 639-1 (
de), optionally followed by the country per ISO 3166-1 alpha 2 (de-AT). A country alone is not allowed, and for the United Kingdom the code isen-GB, noten-UK. - Only reachable, indexable pages: Addresses with a redirect, an error status or noindex do not belong in the list.
Hreflang and canonical
Every language version should point to itself with a canonical. If all versions point to a single one with a canonical, the hreflang hint no longer applies to the others, because they drop out of the index. Google advises against automatic redirects based on the browser language, because users and search engines then do not see every version, and because Googlebot usually crawls from the USA and without a language setting. Offer links to the other languages instead.
Checking
- A crawler can check return references, status codes and codes across the whole website. The former international targeting report in Search Console was discontinued in 2022.
- Spot checks in the source code show whether the list is identical on all versions.
- After a relaunch or a change of the address structure, check all groups again.
Common mistakes
- Missing return reference: the most common mistake, which makes the hint ineffective.
- Wrong codes:
en-UK,de-DE-ATor a country without a language. - Hreflang on pages that are not equivalent: The versions have to offer the same content in another language.
- Relative addresses: They are not resolved reliably.
- Forgetting the page itself: The self-reference belongs in every group.
Related terms
- Duplicate content: the same content under several addresses
- Sitemap.xml: report URLs and language versions
- Noindex tag: remove pages from the index
- Google Search Console: monitor indexing and errors
Sources
- Google Search Central: Tell Google about localized versions of your page
- Google Search Central: Managing multi-regional and multilingual sites