Hreflang tag generator

List each language version once and get the complete, reciprocal set of hreflang annotations to put on every one of them.

Codes look valid.

<link rel="alternate" hreflang="en-US" href="https://example.com/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/">
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">

Put the same HTML block on every URL in the list. Each version should also have a self-referencing canonical.

The three rules that break most hreflang setups

  1. Return links. If the English page points to the German page, the German page must point back. One-way annotations can be ignored.
  2. Self-reference. Each page lists itself as well as the alternates.
  3. Valid codes. Language first, optional region second: en-GB, not GB or en-UK.

Test a published page with the canonical tag checker, which also lists and validates hreflang alternates.

Questions

What does hreflang do?

It tells Google which language or regional version of a page to show to which searchers, for example the en-GB page to UK users and the en-US page to US users. It does not change rankings by itself; it swaps in the most appropriate URL.

Does every version need the full set of tags?

Yes. Google asks that each language version list itself and every other version. If page A links to B but B does not link back to A, the annotations may be ignored.

What is x-default?

The fallback URL for users whose language or region matches none of your versions, often a language-selection page or your main international page.

Which codes are valid?

A language code in ISO 639-1 format (such as en, de, pt), optionally followed by a region in ISO 3166-1 alpha-2 (such as en-GB, pt-BR). A region alone is not valid, and the UK is GB, not UK.

Sources