Hreflang Without the Headache

Hreflang tells search engines which language or regional version of a page to show. It's simple in concept, but easy to get wrong. Here's a practical way to do it, and to know whether you need it.

Hreflang Without the Headache — Troiana insight cover

In short

Hreflang tells Google which language or region version of a page to show users. Each page lists all its versions, including itself, using valid codes such as en-gb or de, and every version has to link back. Add x-default for a fallback. It's a hint, not a ranking booster, and you only need it if you have equivalent pages in several languages or regions.

What it does

Suppose you've got English and German versions of a page, and separate UK and US versions. Hreflang tells Google that these belong together, and which one suits which user. See Google's documentation.

It helps with:

  • Showing the right language version in search results
  • Reducing the chance that very similar regional pages, such as UK and US, compete or get treated as duplicates

It doesn't:

  • Improve rankings on its own
  • Translate anything
  • Redirect anyone
  • Guarantee which version shows up. It's a signal, not a directive.

Bing has historically relied more on the content-language signal, and other search engines differ, too. AI crawlers may ignore it altogether. So write clear pages that are obviously in their stated language, whatever markup you add.

Do you need it?

Yes, if you've got equivalent pages in more than one language, or the same language adapted for different regions, with differences in prices, currency or spelling.

Probably not, if you've got one language and one market, or your pages are only partly translated, such as translated menus with English content.

If you've got only a few important international pages, you could start with those, as it doesn't have to be all or nothing.

A correct example

Here's a page with three versions. Each page contains the same set of tags:

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

The four rules that prevent most problems:

  1. List all versions on every version, including the page itself.
  2. Every link must be reciprocal. If A points to B, B must point to A. Otherwise, Google may ignore those annotations.
  3. Use full, absolute URLs, including https://.
  4. Link only to canonical, indexable, working pages. Don't point to pages that redirect, return an error or have noindex.

Getting the codes right

The format is a language, optionally followed by a region.

CodeMeaningNote
deGerman, anywhereFine for most sites
de-atGerman, in AustriaUse only if the page is really tailored
en-gbEnglish, UKCorrect; “en-uk” is wrong
sqAlbanian“al” is wrong
zh-hansSimplified ChineseScript code
x-defaultFallback for othersOften a language picker or your main version

Language uses ISO 639-1, and region uses ISO 3166-1 Alpha-2. Region alone, like gb, isn't valid. Some common mistakes: en-uk, en-eu (EU isn't a country code), jp rather than ja, and cz instead of cs.

Wrong
en-uk
al
Right
en-gb
sq
The two mistakes named above: the region code for the UK is GB, and the language code for Albanian is sq.

x-default

x-default says which page to use if no other version matches the user. Use it for a page that lets people choose, or for your main international version. It's optional, but recommended.

Three ways of adding it

MethodBest forDrawback
HTML headSmall and medium sitesAdds code to every page
XML sitemapLarge sites, many versionsHarder to inspect by eye
HTTP headersPDFs and non-HTML filesRarely needed otherwise

Choose one method, and use it consistently. A sitemap entry looks like this:

<url>
  <loc>https://www.example.com/uk/pricing/</loc>
  <xhtml:link rel="alternate" hreflang="en-gb" href="https://www.example.com/uk/pricing/" />
  <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/preise/" />
</url>

Your sitemap also needs the xhtml namespace declared on its urlset element.

Hreflang and canonicals

They need to agree. Each language version should have a canonical tag pointing to itself.

A common error is pointing every translated page's canonical to the English version. That tells Google to ignore the translations, which contradicts your hreflang.

A common error
/de/pricing/
canonical: /uk/pricing/
// says the German page is a copy
They agree
/de/pricing/
canonical: /de/pricing/
hreflang lists both versions
Invented paths. Each language version is canonical for itself. The translation isn't a duplicate.

Other common mistakes

  • Missing return links, often because one page was unpublished
  • Missing self-reference
  • Linking to the wrong page, such as the homepage of another language, rather than the equivalent page
  • Automatic IP redirects. Don't force people to a version based on location. Googlebot crawls mainly from the US, and might never see your other versions. Suggest a version with a banner, instead.
  • Inconsistent URLs, with or without trailing slashes
  • Machine translations of low quality, which won't help however good your markup is. See what scaled content abuse is.
  • JavaScript-only tags, which may be missed
  • Tags outside the head, or a broken head that ends early because of an invalid element

Generate it, don't handwrite it

Maintaining this by hand soon becomes impossible. For 500 pages in 5 languages, that's 2,500 pages with 5 or 6 tags each. Generate it from your content system, based on a shared translation ID. Plugins can do this in WordPress and other CMSs, and frameworks offer helpers. Check the output, and don't just trust the plugin.

Decide what happens when a translation doesn't exist. Usually, you'd simply leave out that version's tag.

How to test it

  1. View source on a few pages. Are the tags in the raw HTML?
  2. Crawl your site with a tool like Screaming Frog, which reports missing return links and invalid codes.
  3. Use URL Inspection in Search Console to see which canonical Google selected. Google's old international targeting report has been retired, so third-party tools matter more.
  4. Check Search Console's performance data by country, to see which pages rank where.
  5. Search from other countries, using a VPN or Google's region settings. It's a rough check.

See Search Console's numbers explained.

What about domains and folders?

Hreflang works with any structure: example.de, de.example.com or example.com/de/. Folders are usually easiest to run, as they share one domain's authority, and they're often a sensible default. See subdomain or subfolder for a blog for similar considerations.

Before you launch

  • Pages are properly translated, and localised for prices and contact details
  • All versions are live and return 200
  • Canonicals point to themselves
  • Tags are reciprocal, with valid codes
  • Navigation lets people switch language, and returns them to the equivalent page
  • There are no forced redirects
  • Sitemaps are updated

Then check again after any migration, because this is one of the first things to break.

If you're launching a site in more than one language or country and want it done properly, book a call.

Common questions

What is hreflang used for?

It tells search engines which language or regional version of a page to show to different users. It helps connect translated or localised pages and can reduce confusion between similar versions. It isn't a ranking boost, and it's a signal rather than a command.

Do I need hreflang on a single-language site?

No, not if you've only got one language and one market. It's useful when you've got equivalent pages in more than one language, or in the same language for different regions, with real differences such as price or currency.

What is x-default in hreflang?

It specifies the fallback page for users who don't match any listed language or region. It's often a language selection page, or your main international version. It's optional, but Google recommends including it where it makes sense.

Why is my hreflang not working?

Common causes include missing return links, a missing self-reference, invalid codes such as en-uk, URLs that redirect or are noindexed, and canonicals pointing to another language. Crawl your site with an SEO tool to find these errors.

Have something worth building right?