What hreflang does
Hreflang tells Google that several pages are the same content in different languages or for different countries, so it shows each searcher the right one. A UK shopper sees your en-GB page with prices in pounds; a shopper in Mexico sees es-MX. It doesn't improve rankings by itself. It makes sure the version that ranks is the right one.
Hreflang code format
- Language first, as an ISO 639-1 code:
en,de,ja,zh. - Optionally a country, as an ISO 3166-1 alpha-2 code:
en-GB,es-MX,fr-CA. - Never a country alone.
hreflang="us"is invalid; useen-US.
| Common mistake | Correct |
|---|---|
| en_US | en-US (hyphen, not underscore) |
| en-UK | en-GB (the UK's code is GB) |
| jp | ja (jp is the country; the language is ja) |
| cn | zh, or zh-CN for mainland China |
| es-419 | Google only reads two-letter countries: list es-MX, es-AR and so on |
Three rules Google checks
- Return links. If page A points to page B, page B must point back to A. One-way hreflang is ignored.
- Self-reference. Each page includes a tag pointing to itself, which the generated set already does.
- x-default. Name a fallback for everyone else, usually your main page or a language picker.
HTML, sitemap or header?
All three work the same for Google; pick one and use it consistently. HTML tags in the <head> are easiest for small sites. The XML sitemap is easier to keep in sync for large sites. HTTP headers are the only option for PDFs and other non-HTML files.
Questions people ask
What is x-default in hreflang?
The page for visitors whose language or country you haven't listed. It's often your main homepage or a language picker.
Is it en-UK or en-GB?
en-GB. Hreflang uses ISO country codes, and the United Kingdom's code is GB.
Do I need hreflang if I only have one language?
No. Hreflang is only for sites with the same content in more than one language or for more than one country.
Does hreflang affect rankings?
Not directly. It helps Google show the right version to each searcher, which can improve clicks and stop your own versions competing.
Can I put hreflang in my sitemap instead?
Yes. Choose XML sitemap above. Each URL lists all its alternates with xhtml:link tags.