
Key points
- hreflang links equivalent pages in different languages or regions. It helps Google show the right version in results; it does not translate anything.
- Every version must list all versions, itself included, and each page must link back. One-way links are ignored.
- Codes are language (
en) with an optional region (en-GB). Addx-defaultfor visitors who match none.
What hreflang does
Suppose you sell in the UK and the US with near-identical English pages, or you publish a page in English, German and French. Search engines may treat them as duplicates or show the wrong one to a visitor. The hreflang annotation groups the equivalent pages into a set and says which language and region each is for.
Google treats it as a signal, not a command. It does not stop other versions from ranking and it does not translate or redirect visitors.
How to write it
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/">
<link rel="alternate" hreflang="en-us" href="https://example.com/us/">
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">
- The language is a two-letter ISO 639-1 code:
en,de,fr,ro. - The optional region follows after a hyphen and is an ISO 3166-1 country code:
en-GB,es-MX. You cannot use a region on its own. x-defaultmarks the fallback page, for example a language selector or your main version.- Use absolute URLs including
https://.
Three ways to add it
- In the HTML head (shown above), on every version. This is the most common.
- In HTTP headers, using a
Linkheader. Useful for PDFs and other non-HTML files. - In the XML sitemap, with
xhtml:linkentries for each URL. Handy for large sites. See XML sitemaps.
Pick one method per site and keep it consistent, because mixing them makes mistakes harder to find.
The rules that trip people up
- Return links. If page A lists page B, page B must list page A. Otherwise the pair is ignored.
- Self-reference. Each page includes itself in its own set.
- Canonicals agree. Each version should be its own canonical. Pointing all versions' canonicals at one language undoes the setup.
- Targets must work. Alternates should return 200 and be indexable, not redirect, return errors or carry
noindex. - Valid codes. A common slip is
en-UK; the correct code for the United Kingdom isen-GB. Another is using a country as a language, such asukfor the UK (that is the code for Ukrainian). - Page equivalents only. Link a page to its translation, not to the other language's home page.
When you need it, and when you do not
- Needed: the same content in several languages, or one language with real regional differences such as currency, spelling or shipping.
- Not needed: a single-language site, or a site where visitors from other countries are happy with the same page.
- Translate properly. Machine-translated pages left unreviewed give a poor experience, whatever the tags say.
- Do not redirect visitors automatically by IP address or browser language, because crawlers and users may then never reach the other versions. Offer a visible language switcher instead.
How to check it
- Run a page through the canonical and hreflang checker. It validates the codes, checks the page lists itself, and fetches alternates to confirm they link back.
- Repeat for each language version, since errors are often on only one side of a pair.
- In Google Search Console, watch the Pages report for alternate-page and canonical issues after a rollout.
Alternate pages must be reachable by crawlers. If robots.txt blocks one version, search engines cannot read its tags, and the pair will not be confirmed.
FAQ
Is hreflang a ranking factor?
No. It helps search engines pick the right version for a visitor but does not boost rankings. Pages still need to rank on their own merits.
What is x-default?
A special value that names the fallback page for visitors whose language or region matches none of your versions, often a language selector or the main version.
Do I need hreflang if I only have one language?
No. It is only for sites with equivalent pages in several languages or regions.
Why does the checker say return tags are missing?
The alternate page does not link back to the page you tested. Add the full set of hreflang links to every version in the group.
Can I use hreflang between different domains?
Yes. Versions can live on different domains or subdomains, as long as each lists the full set and links back.