SEO100
SEO method 23 of 100

Hreflang: How to Tag Language and Country Versions Correctly

Advanced Medium impact A few hours Technical SEO

Updated · First published

Short answerHreflang tells Google which language or regional version of a page to show each searcher. Every version must list itself and all the others, with return links, absolute URLs, valid ISO codes (language first, region optional) and an x-default fallback.

Hreflang is an annotation, written as rel="alternate" hreflang="...", that tells Google a page has translated or regionally adapted versions and which version belongs to which audience. A German searcher in Austria then sees your de-AT page and not the UK English one.

What is hreflang?

It is a set of links that connects equivalent pages: the English page, its German translation, its French translation, and so on. Google’s documentation says it helps Google serve the right localized version, and that localized pages count as duplicates only when the main content stays untranslated. A page translated into another language is not a duplicate. Hreflang matters most for pages that are near-identical within one language, such as a US and a UK English store.

Google says it does not use the HTML lang attribute or hreflang to detect the language of a page. It works that out from the content itself. Hreflang only groups the versions.

Why does hreflang matter for SEO?

  • Right page, right searcher. Searchers land on the version in their language and currency.
  • Fewer duplicate problems between regional versions that share most text.
  • No ranking boost. Hreflang does not lift a page. It swaps the URL Google shows, among versions that already rank.

Skip it if your site has one language and one market. Tags on a single-language site do nothing.

How is an hreflang tag written?

Each value holds a language code (ISO 639-1, two letters) and optionally a region code (ISO 3166-1 Alpha 2). Google lists the rules plainly:

Value Meaning
en English, any region
en-GB English for the United Kingdom
de-AT German for Austria
zh-Hant Traditional Chinese (script code, ISO 15924)
x-default Fallback when no other language or region matches

Two traps: a region code alone is invalid (hreflang="gb" does nothing), and made-up codes such as es-419 or the reserved codes EU, UN and UK have no effect. The code for the United Kingdom is GB.

Google accepts three equivalent ways to declare versions. Pick one: using all three adds no benefit. The HTML version goes in the <head> of every page:

<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 other two methods are an HTTP Link header (for PDFs and other non-HTML files) and xhtml:link entries inside your sitemap, which suits large sites because it keeps annotations out of the page weight (see XML sitemaps).

How do you set up hreflang, step by step?

  1. List your versions and pair every page. Build a table: for each page, the matching URL in each language or region. Pages with no equivalent in a market get no tag for it.
  2. Choose the codes. Language first, region only when two versions of the same language differ (US and UK pricing, spelling, shipping). Check each code against the ISO lists.
  3. Make every version list itself and all others. Page A names A, B and C. Page B names A, B and C. This gives the return links Google requires: if a page does not link back, Google ignores the annotation.
  4. Use absolute URLs with https://. Alternates may sit on different domains or subdomains.
  5. Add x-default pointing to a language selector or your global default page.
  6. Add a generic version (en) when you have several regional variants of one language (en-GB, en-AU), so other English speakers get a match.
  7. Keep it consistent with canonicals. Each localized page carries a self-referencing canonical tag. Never canonicalize the German page to the English page: that tells Google to drop the German version. Put only the canonical HTTPS URLs in hreflang.
  8. Check the result. Crawl the site with Screaming Frog and open the hreflang report. Look for missing return links, non-200 targets and invalid codes.

How do you measure the result?

Search Console no longer has the old International Targeting report, so you check the outcome indirectly:

  • In Performance, filter by country and look at the pages that get impressions in each market. The right version should show up, not the wrong one.
  • In URL Inspection, confirm the page is indexed and the canonical is the one you declared.
  • In a crawler, count pages with missing return links or non-canonical alternates. The target is zero.
  • Search from the target country (or use a result-checking tool) and confirm the localized URL appears.

What mistakes should you avoid?

  • Missing return links. This is the most common failure, and Google ignores both sides.
  • Wrong codes. en-UK should be en-GB, and a country on its own is invalid.
  • Pointing to redirected, noindex, blocked or canonicalized URLs. Alternates must be indexable.
  • Auto-redirecting visitors by IP address. Googlebot crawls mostly from the US and never sees your other versions. Show a banner suggesting the right version and let people choose.
  • Hreflang on half-translated pages. Keep the same content on every version, apart from the translation.
  • Mixed methods that disagree, such as HTML tags saying one thing and the sitemap another.

Where can you learn more?

The structure behind these tags (country domains, subfolders, subdomains, keyword research per market) is in international SEO. If you are new to technical SEO, the free digital marketing module of the Fe/male Switch startup school covers the groundwork. Next steps on SEO100: fix your URL structure before you duplicate it per language.

Earlier versions of this directory listed this as: Hreflang Implementation.

Learn SEO as part of building a startup

Fe/male Switch is a startup school and game where you build a real company step by step. Its free digital marketing module covers SEO, and the free startup tools help with the rest.