hreflang is an attribute you add to a link that points to another language or regional version of the same page; the whole <link> line is what people call the hreflang tag. You list every version, each with a code like de or en-GB, and Google uses that list to show searchers the version that matches their language and region. Google Search Central
Without it, a reader in Germany might land on your English page even though a German one exists. Google may find your other versions on its own, but telling it is more reliable.
When you need hreflang
Use it when the same page exists in more than one version for different languages or places, for example:
- the whole page is translated, like German and English versions of each page
- the content is the same language with small regional differences, like English pages for the US and the UK with different prices or spelling
- only the template is translated (navigation and footer), while the main content stays in one language, as on many forums
A note on duplicate content: translated versions aren't duplicates of each other. Regional versions in the same language are close copies, and hreflang is how you tell Google they're meant as alternatives, not as repeats.
Hreflang doesn't tell Google what language a page is in. Google works that out from the text itself, so the page must really be in the language you label it with.
What the markup looks like
Say a shop has a generic English page, a UK page, a German page and a language picker. Each of the four pages carries the same set of rel="alternate" links in its <head>, including one to itself:
<link rel="alternate" hreflang="en" href="https://example.com/en/shoes/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/shoes/">
<link rel="alternate" hreflang="de" href="https://example.com/de/schuhe/">
<link rel="alternate" hreflang="x-default" href="https://example.com/choose-country/">
Three rules make it work:
- Every version lists every version, itself included. The set is identical on each page.
- Links must go both ways. If the German page points to the UK page, the UK page must point back. Google ignores pairs that don't, so another site can't claim to be your translation.
- URLs must be complete, with
https://. Not/uk/shoes/and not//example.com/uk/shoes/.
The x-default line names the page for everyone whose language you don't serve, usually a language or country picker. See x-default for when to use it.
Choosing the codes
A code is a language, optionally followed by a region: the language in ISO 639-1 format, the region in ISO 3166-1 Alpha 2. Google accepts upper or lower case.
| You want to reach | Use | Not |
|---|---|---|
| German speakers anywhere | de |
|
| English speakers in the UK | en-GB |
en-UK (UK isn't the country code) |
| French speakers in Belgium | fr-BE |
be (that's Belarusian, not Belgium) |
| Spanish speakers in Latin America | one code per country, such as es-MX, es-AR |
es-419 (not supported) |
| Readers of Traditional Chinese | zh-Hant, or zh-TW for Taiwan |
A region on its own is never valid; the first code is always the language. Codes reserved for other uses, like EU or UN, have no effect.
If you have several versions for one language, such as en-GB, en-AU and en-CA, also give a plain en version for English speakers everywhere else. It can be one of the regional pages.
Three places to put it
Google treats all three the same, so pick the one that's easiest to keep right:
- In the HTML
<head>, as above. The usual choice for web pages. The links must sit inside a valid<head>, and each<link>should carry only the hreflang annotation, not other attributes such asmedia. - In an HTTP
Linkheader, for files that have no<head>, like PDFs. - In your XML sitemap, with
<xhtml:link>entries under each URL. Useful when you have many versions and editing every page is hard.
Using more than one method gives no extra benefit and is harder to keep in sync.
Hreflang and canonical tags
Each language version should be its own canonical page. If you use a canonical tag on a version, point it to a page in the same language, not to your English page. Google Search Central Canonicalizing every version to one page tells Google the others are duplicates, which works against the hreflang set.
Common mistakes
- Missing return links. Typically, a new language version links out to the others, but nobody adds it to the existing pages.
- Invented codes.
en-UK,es-419or a country code alone. - Relative URLs in
href. - Hreflang pointing at URLs that redirect or carry noindex. Google can only show a version it can index, so list the final address of each one.
- Redirecting visitors by guessed language. Google advises against sending people to another language version automatically; offer a language switch instead.
Hreflang is one part of international SEO. The rest is deciding which markets get their own pages, and making those pages genuinely useful to readers there.