Technical SEO

Hreflang: What It Is and How to Set It Up Correctly

Updated: October 2, 20263 min read
Share

Hreflang is an attribute of the HTML <link> tag that tells search engines which language and regional version a page is, so users see the variant that matches their language and location in search results. The tag goes in the <head> of every language version of a page and points to all its alternatives, including the page itself.

How does it work?

Hreflang is a signal for Google, not a directive: the search engine weighs the attribute alongside other factors (content language, server location, user behavior), so a misconfigured hreflang may be partly ignored.

Attribute syntax

The attribute consists of an ISO 639-1 language code and, optionally, an ISO 3166-1 Alpha 2 country code joined by a hyphen (for example, uk-UA, en-US, en-GB). The x-default value marks the default page for users whose language or region doesn't match any of the listed versions.

The reciprocity principle

All language versions of a page must reference each other, including a self-referencing hreflang — a tag where the page points to itself. If page A links to B but B doesn't link back to A, Google may ignore the entire block of hreflang relationships.

Why do you need it?

Hreflang prevents users from seeing an irrelevant language version in search results and eliminates internal cannibalization, where several language versions of the same page compete for the same queries.

Correct setup also improves behavioral signals (a lower bounce rate), because users land straight on a page in their own language instead of hunting for a language switcher.

Example

<!-- On the Ukrainian version of the page -->
<link rel="alternate" hreflang="uk-UA" href="https://example.com/ua/page/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en/page/" />
<link rel="alternate" hreflang="pl-PL" href="https://example.com/pl/page/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/page/" />
<!-- Alternative method via Sitemap.xml -->
<url>
  <loc>https://example.com/ua/page/</loc>
  <xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en/page/" />
  <xhtml:link rel="alternate" hreflang="uk-UA" href="https://example.com/ua/page/" />
</url>

Common mistakes

Pages reference each other incompletely (A → B, but not B → A), so Google may discard the whole set of hreflang relationships on the page.

Wrong language or country code

Using non-standard codes (for example, ua instead of uk for Ukrainian — ua is a country code, not a language code) makes the attribute unreadable to the search engine.

Hreflang and canonical conflict

If every language version's canonical points to one "main" language instead of itself, localized pages drop out of the index despite correct hreflang.

Missing self-referencing hreflang

The page doesn't include a link to itself in its hreflang block, which breaks the reciprocity requirement.

Hreflang pointing to a page blocked in robots.txt

If an alternate language version is blocked from crawling, Google can't confirm its content and ignores the corresponding hreflang entry.

How to check it?

You can check a specific page with the URL Inspection tool in Google Search Console, or manually by viewing the <head> source of each language version and making sure all versions reference each other.

FAQ

Is it mandatory to specify a country code in hreflang?

No, the country code is optional. You can specify just the language (uk) for all Ukrainian speakers regardless of country, or add the region (uk-UA) for more precise targeting.

What does x-default mean in hreflang?

It's the default page for users whose language or region doesn't match any of the listed versions — often a language selection page or the main international version of the site.

Does hreflang affect a site's search rankings?

Hreflang is not a direct ranking factor, but correct setup prevents the wrong version of a page from being shown, which indirectly affects CTR and behavioral signals.

Can I use hreflang without multiple language versions of the content?

Yes, you can declare regional variants of the same language (for example, en-US and en-GB with identical text) if you need to show different versions to different English-speaking regions — for instance, with different prices or currency.

Related terms

Prepared by the LuchanLabs team

Was this article helpful?