Skip to content
RankThat

Hreflang

Hreflang is an HTML attribute that tells search engines which language and country each version of a page is for, so searchers see the version that fits them.

If you publish the same page in more than one language, or in one language for more than one country, hreflang helps Google show the right one. A searcher in Mexico gets the Spanish page, a searcher in the UK gets the British English page, and everyone else gets the default.

Hreflang doesn’t make a page rank higher. It swaps in the most suitable version of a page that would already rank.

Why it matters

Bean & Barrel Coffee ships to the US and Canada and opens a French-language store for Quebec. Without hreflang, Google may show the English US page to a shopper in Montreal, complete with US prices and shipping. The US and Canadian English pages are also near-identical, so Google might treat them as duplicate content and pick only one to index. Hreflang tells Google these pages are deliberate alternates.

The tags

Each version lists every version, including itself, in its <head>:

<link rel="alternate" hreflang="en-us" href="https://www.example.com/us/" />
<link rel="alternate" hreflang="en-ca" href="https://www.example.com/ca/" />
<link rel="alternate" hreflang="fr-ca" href="https://www.example.com/ca/fr/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

The value is a language code (ISO 639-1, such as en or fr), optionally followed by a region code (ISO 3166-1 Alpha 2, such as us or ca). x-default names the page to show when no other version fits, often a country selector or the main international page.

Hreflang can also go in HTTP headers or in your XML sitemap, which is easier to manage on large sites.

Common mistakes

  • Missing return links. If the US page points to the Canadian page, the Canadian page must point back. One-way annotations are ignored.
  • Wrong codes. en-uk is invalid; the United Kingdom is gb. A region code on its own (hreflang="ca") is also invalid, because a language is required.
  • Conflicting canonicals. Each language version should have a self-referencing canonical tag. Canonicalizing all versions to the US page tells Google to ignore the others.
  • Pointing to redirected or noindexed URLs.
  • Automatic redirects by IP address that stop Googlebot (which mostly crawls from the US) from ever seeing the other versions.

How to check

Spot-check a page’s source and make sure every alternate lists the same full set. A Site Audit crawl flags invalid hreflang codes and alternates that don’t link back. Search Console’s URL Inspection tool shows which canonical Google chose for each version, which quickly reveals when Google has folded your country pages together.

Do this month’s SEO in an afternoon.