If you publish the same page in several languages, search engines have a puzzle: which version should they show to which searcher? Hreflang is how you tell them. It’s one of the few technical parts of multilingual SEO (search engine optimization, the work of helping people find your pages in search), and it’s worth understanding even if a developer adds it for you.

What hreflang does

Hreflang is an attribute, a small label inside your page’s code. It says, in effect: “This page is in English for the UK. There is also a German version here, and a French version for Canada here.”

Search engines that support it use that information to show the right version in search results. Someone searching in German is more likely to see your German page; someone in Canada searching in French is more likely to see your Canadian French page.

It does not translate anything, and on its own it doesn’t push pages higher in search results. It helps the right page reach the right reader.

What it looks like

The most common way to add hreflang is a set of lines in the head of each page. For a page that exists in UK English, German and Canadian French, every one of those three pages would carry the same set:

<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/">
<link rel="alternate" hreflang="de" href="https://example.com/de/preise/">
<link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/tarifs/">
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/">

Each line pairs a language code with the address of that version. The last line, x-default, names the page to show anyone who doesn’t match a listed language, often a language chooser or your main international page.

Hreflang can also be added in your XML sitemap, the file that lists your pages for search engines, or in the page’s HTTP headers, which suits files such as PDFs. Pick one method and use it consistently.

The codes

A hreflang value is a language code, optionally followed by a region code:

ValueMeans
deGerman, for any region
de-ATGerman, for Austria
es-MXSpanish, for Mexico
en-GBEnglish, for the United Kingdom
x-defaultThe fallback for everyone else

The language comes first and the region second. A region on its own isn’t valid.

The rules that make it work

  1. Every version lists every version. Each page in the set carries the full list, including a line pointing to itself.
  2. Links go both ways. If the English page points to the German one, the German page must point back. One-way links are generally ignored.
  3. Point to the final address. Each link should go to a live page, not to one that redirects elsewhere or that you’ve hidden from search.
  4. Match like with like. Link each page to its true equivalent: pricing to pricing, not pricing to the German home page.

Common mistakes

  • Invented codes. en-UK looks right but isn’t valid; the code for the United Kingdom is GB.
  • Missing return links, often after a new language version is added to some pages but not others.
  • Pointing at redirects or at pages that are blocked from search.
  • Mixed signals. A page whose hreflang says one thing and whose canonical tag, another label that names the main version of a page, points somewhere else.

Where AI helps

AI assistants are useful for drafting a hreflang set from a list of URLs, explaining an error report or checking a set for missing return links. Treat the output as a draft: check the codes against a reference list and test the live pages with a crawler or your search engine’s own tools.

Draft and check a hreflang set
Here are the language versions of one page on our site:
[language and region, URL — one per line]
Our fallback page for everyone else: [URL]

1. Write the full set of hreflang link tags that every one of these pages should include.
2. Check each language and region code and flag any that don't look valid.
3. List anything that looks inconsistent, such as a URL that seems to belong to a different page.

Not every search engine uses hreflang in the same way. If you’re targeting a market where another search engine is popular, check that engine’s own guidance as well. Our guide to multilingual SEO covers the rest of the picture.

Key takeaways

  • Hreflang tells search engines which language or regional version of a page to show to whom.
  • Every version must list all the others and itself, and the links must go both ways.
  • Use valid codes, such as en-GB rather than en-UK, and add an x-default for everyone else.
  • Hreflang points people to the right version. It doesn’t translate pages or improve rankings by itself.