Indexing and redirects

Hreflang tags explained, with examples

If your site has pages in more than one language or for more than one country, hreflang tells Google which version to show each searcher. Here's how it works and how to get it right.

Hreflang is an HTML attribute that tells search engines a page has versions in other languages or for other regions. Google uses it to show the right version in each country's results, for example the UK English page to searchers in Britain and the Spanish page to searchers in Spain.

What hreflang looks like

Each version of the page lists all versions, including itself:

<link rel="alternate" hreflang="en-us" href="https://example.com/us/">
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/">
<link rel="alternate" hreflang="es" href="https://example.com/es/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">

The language and region codes

  • Language uses an ISO 639-1 code: en, es, de, fr.
  • Region is optional and uses an ISO 3166-1 alpha-2 code: us, gb, mx.
  • Combine them as language-region: en-gb, es-mx.
  • A region alone isn't valid. gb on its own doesn't work. And the UK is gb, not uk.

Free tool

Hreflang Checker

Check that a page's language versions are set up correctly and link back to each other.

Free, no sign-up. Clarnic reads the page the way a search engine does.

Open the full Hreflang Checker page →

What x-default does

x-default is the fallback for searchers who don't match any listed version. Point it at a language selector page or your main international version.

Hreflang only works when it's reciprocal. If the English page lists the Spanish page, the Spanish page must list the English page back. If the return link is missing, Google may ignore the pair. This is the single most common hreflang error.

Three ways to add hreflang

MethodBest for
<link> tags in the page headMost sites
HTTP headersPDFs and other non-HTML files
XML sitemap entriesLarge sites with many versions

Use one method consistently. Mixing them makes errors harder to find.

Common hreflang mistakes

  1. Missing return links between versions.
  2. Wrong codes: en-uk instead of en-gb, or a country code with no language.
  3. No self-reference: each page should list itself.
  4. Hreflang pointing to redirects, 404s or noindexed pages. Every target must be a live, indexable page.
  5. Conflicting canonicals: each language version should have a canonical pointing to itself, not to the English page.
  6. Automatic redirects by IP or browser language, which can stop Googlebot (which mostly crawls from the US) from ever seeing other versions.

Do I need hreflang?

Only if you have genuinely different versions of the same content for different languages or regions. A single-language site doesn't need it. If your versions are near-identical English pages for several countries, hreflang is especially important, because without it Google may treat them as duplicates and show the wrong one.

How to check hreflang

Enter a page in the checker on this page. It lists every hreflang tag, validates the language and region codes, checks for x-default and a self-reference, and visits each alternate to confirm it links back. That covers the mistakes that cause most hreflang failures.

Questions

What are hreflang tags used for?

They tell search engines which language or regional version of a page to show to searchers in different countries or with different languages.

Is hreflang a ranking factor?

No. It doesn't boost rankings; it helps Google show the correct version of a page that already ranks.

What is x-default in hreflang?

The fallback version for searchers who don't match any of the listed languages or regions, often a language selector or the main site.

Why is Google ignoring my hreflang?

Usually because return links are missing, the codes are invalid, or the alternate URLs redirect, return errors or are noindexed.

See what to fix on your website today.

Free plan, no credit card. Your first fixes in about a minute.