What is hreflang? Definition, syntax and how it works

Hreflang is an HTML attribute that tells search engines which language or regional version of a page to show to which users. Google introduced the rel=”alternate” hreflang annotation in December 2011 and added the x-default value in April 2013. Google accepts 3 equivalent ways to implement it, and every version must link back to the others, or the annotations are ignored.

Updated: 17 October 20263 min read
Infographic: anatomy of a hreflang annotation, rel alternate, language code, region code, x-default and return links
Source: Google Search Central, Localized versions of your page

How does hreflang work?

Hreflang works by listing every language or country version of a page, including the page itself, in a set of alternate links. When Google finds the same content in Polish, German and English, the annotations help it swap in the right URL for a searcher in Warsaw, Berlin or London. Hreflang does not boost rankings; it decides which of your own URLs appears in each market.

A basic set for one page looks like this in the head:

  • <link rel=”alternate” hreflang=”pl-PL” href=”https://example.com/pl/” />
  • <link rel=”alternate” hreflang=”de-DE” href=”https://example.com/de/” />
  • <link rel=”alternate” hreflang=”x-default” href=”https://example.com/” />

Hreflang syntax: language, region and x-default

The hreflang value is a language code in ISO 639-1 format, optionally followed by a region code in ISO 3166-1 Alpha 2 format. The layers below summarise the rules from Google Search Central.

Language code

The language code comes first and is required: pl, de, en. A region code alone, such as PL, is invalid.

Region code

The optional region narrows the target: en-GB for the United Kingdom, de-AT for Austria. Use GB, never UK, because Google ignores UK, EU and UN.

x-default

The reserved x-default value names the fallback page for users whose browser language matches none of your versions. It fits a language selector or a global English homepage.

3 ways to implement hreflang

Google treats HTML link tags, HTTP headers and XML sitemaps as equivalent, so pick one method per site:

MethodWhereBest for
HTML link tagsIn the page headSmall and mid-size sites
HTTP Link headerServer responsePDFs and other non-HTML files
XML sitemapxhtml:link entriesLarge e-commerce sites with many versions

Hreflang in international SEO

Hreflang is the foundation of every multi-market site I audit, because without it Google often shows the wrong country version, for example a German shop page with euro prices to a Swiss user. It works together with the site structure (ccTLD, subfolder or subdomain, see top-level domain), canonical tags and translated content. Google also recommends separate URLs with hreflang over serving different content by IP, because Googlebot mostly crawls from US addresses and does not send an Accept-Language header. That is why IP-based geolocation redirects are risky for SEO.

Common hreflang errors

  • Missing return links: page A points to B, but B does not point back.
  • Wrong codes: en-UK instead of en-GB, or a region with no language.
  • Non-canonical URLs: hreflang pointing to redirected, noindexed or 302-redirected pages.
  • Missing self-reference: the page does not list itself in the set.

On large sites, each wrong URL in the set also costs crawl budget.

Hreflang and other search engines

Bing does not rely on hreflang in the same way. Its webmaster blog lists the content-language meta tag, the HTML lang attribute, HTTP headers, ccTLDs and IP lookup as its language and country signals. For markets where Bing has meaningful share, add a content-language meta tag as well.

Pro tip: Generate hreflang from one source of truth (your CMS or a mapping sheet), never by hand. In my audits, most hreflang problems come from a single version being added or removed without updating the other languages.

Need a hreflang setup for Poland, Germany or the Czech Republic? See my international SEO consultancy or read the guide to SEO in Germany.

Frequently asked questions about Hreflang

Does hreflang improve rankings?

Hreflang does not raise rankings directly. It tells Google which of your existing language or country versions to show, which reduces wrong-market traffic and improves click-through and conversion.

What is x-default in hreflang?

x-default is a reserved hreflang value that marks the fallback page for users whose language settings match none of your versions. Google introduced it in April 2013.

Does Google use hreflang to detect a page's language?

Google does not use hreflang or the HTML lang attribute to detect language. It detects language with its own algorithms and uses hreflang only to pick between alternate versions.

Should I use hreflang in the sitemap or in HTML?

Use either one, because Google treats HTML tags, HTTP headers and XML sitemaps as equivalent. Sitemaps are easier to maintain on large e-commerce sites with many language versions.

Related terms

International SEO · AI SEO (GEO)

Grow in every market, and get cited by AI

Hreflang decides which country sees which version of your site, and a single broken return link can send German buyers to your Polish shop. I audit and fix hreflang for multi-market sites so each market gets its own pages in Google and in AI search.

I help SaaS and e-commerce brands win organic traffic across Europe and the US, and get their brand recommended in ChatGPT, Gemini, Perplexity and Google AI Overviews. Every project starts with a free audit of your site, your markets and your visibility in AI answers.

Write to Adrian

Have a question about this term or your SEO?

Send a short message about your website, the markets you sell in and what you want to achieve. You get a reply from me, not from a sales team.

  • Free preliminary SEO and AI visibility audit
  • Strategy for international and multilingual markets
  • Reply within one business day
Book a free call
Adrian Dąbrowiecki

Write to Adrian

Adrian Dąbrowiecki · Marketer Coffee

Tell me about your site and your goals. I usually reply within one business day.