Skip to main content

What is hreflang?

hreflang is an HTML attribute that tells search engines the language and target geographic region of a web page. The hreflang attribute links pages with identical content but in different languages so that Google can display the appropriate language or country version to each user in the search results. This way, a German user is directed to the German version of the page, while a U.S. user is directed to the English version.

The hreflang Attribute Explained: Language Indicators for International SEO Using the Codes de-DE, en-US, and x-default

The attribute is the cornerstone of international SEO. Without hreflang, Google decides on its own which language version to rank, and may show a German searcher the English page. hreflang actively controls this assignment.

Brief Overview of the Term

Characteristic Specification
Part of speech Noun / technical attribute (neuter: the hreflang attribute)
Pronunciation "href-läng" (from " hyperlink reference language")
Hyphenation href·lang
Related Terms Canonical, x-default, ISO 639-1, ISO 3166-1

How does the hreflang attribute work?

hreflang works through cross-references between language versions. Each page lists, via link-element lists all its language variants, including itself. A typical entry in the <head> It looks like this:

<link rel="alternate" hreflang="de-DE" href="https://beispiel.de/produkt/" />
<link rel="alternate" hreflang="en-US" href="https://beispiel.de/en/product/" />
<link rel="alternate" hreflang="x-default" href="https://beispiel.de/" />

The value consists of two parts: the language and, optionally, the country. de stands for German, de-AT for German in Austria. Google reads this information, groups the pages together as a single unit, and displays the correct version for each search query.

The most important rule: hreflang must be reciprocal. If the German page links to the English page, the English page must link back to the German page. If thisreturn link is missing, Google will ignore the hreflang tag entirely.

hreflang return link: reciprocal links between language versionsThe German page uses the hreflang attribute to link to the English page, and the English page links back to the German page. Only this two-way link is accepted by Google.German Pagehreflang="de-DE"example.de/product/English Pagehreflang="en-US"example.de/en/product/Reciprocal link (return link)If the backlink is missing, Google ignores the hreflang attribute.Fig. 1 · taismo
Abb. 1: Der beidseitige hreflang-Verweis (return link) zwischen deutscher und englischer Seite.

What language and country codes does hreflang use?

hreflang combines two international standards. The language code follows ISO 639-1 (two lowercase letters), and the optional country code follows ISO 3166-1 Alpha-2 (two uppercase letters).

  • Language only: hreflang="de" – for all German-speaking regions.
  • Language and Country: hreflang="de-CH" – German for Switzerland.
  • A country alone is not allowed: A country code is never used on its own; the language must be included.

A common mistake: hreflang="en-UK". The correct country code for the United Kingdom is GB, not UK. Google silently invalidates incorrect codes.

What does hreflang="x-default" mean?

x-default marks the fallback page for all users whose language or region does not have its own version. If someone from France visits a website that does not have a French version, Google provides the page marked as x-default An excellent website; often the English homepage or a language selection page.

x-default This is optional, but recommended. Specifying this prevents Google from selecting a random version for regions not covered.

Where is hreflang included?

There are three ways to implement hreflang. All three are equally valid for Google; you choose exactly one per website.

  1. In HTML—<head>: Each link-element per language version. Easy to implement, but the source code becomes large when there are many pages and languages.
  2. In the HTTP header: Useful for non-HTML files such as PDFs, where there is no <head> exists.
  3. In the XML sitemap: Centralized management of all links in one place. Ideal for large websites with multiple languages, because it keeps the page source code lean. The term " sitemap" explains this in more detail.
Three Ways to Implement hreflanghreflang can be implemented in three equivalent ways: in the HTML head, in the HTTP header, or in the XML sitemap. Exactly one method is chosen per website.3 equivalent paths—exactly one per website1HTML-<head>Each link elementLanguage version.Simple, but a lot of source code.2HTTP headersFor files withouthead, e.g., PDFs.Set on the server side.3XML SitemapCentralized Maintenance atone place.Ideal for large sites.Fig. 2 · taismo
Abb. 2: Die drei gleichwertigen Wege, hreflang einzubinden – pro Website wählst du genau einen.

What are the most common hreflang errors?

hreflang is considered prone to errors because even minor discrepancies can throw off the entire mapping. The 4 most common errors:

  1. Missing return link: The link is not reciprocal. Without a return link, Google rejects the page's entire hreflang set.
  2. No self-reference: Each page must also list itself using `hreflang`. If the entry for itself is missing, the set is incomplete.
  3. Incorrect codes: en-UK instead of en-GB or made-up language abbreviations. Only valid ISO codes are recognized.
  4. Conflict with the canonical tag: If a page's canonical tag points to a different language version, the signals contradict each other. A page's canonical tag must always point to itself, while the hreflang attribute points to the alternatives.

Google reports such issues in Google Search Console. Although the former “International Targeting” report has been discontinued, hreflang errors still appear in the coverage and audit reports.

hreflang vs. Canonical: What's the Difference?

The hreflang attribute and the canonical link serve different purposes and complement each other.

  • The canonical tag determines the primary version for URLs with identical content and prevents duplicate content. The canonical tag always points back to its own URL.
  • The `hreflang ` attribute tells Google the language options for a page. `hreflang` treats multiple language versions not as duplicates, but as a related group.

In short: The canonical tag says, “This is the correct URL for this content,” and the hreflang tag says, “And here is the same content in other languages.” Together, they keep multilingual websites organized, which is a core aspect of any technical SEO strategy.

Frequently Asked Questions About hreflang

Does every multilingual website need hreflang?
Yes, as soon as the same content exists in multiple languages or for multiple countries. hreflang prevents Google from ranking the wrong version.

Is hreflang a ranking factor?
No, hreflang does not directly improve rankings. hreflang ensures that the page that is already ranking is displayed in the correct language version, which enhances the user experience and click-through rate.

Does hreflang replace a translation?
No, hreflang only points to existing language versions. You have to create the actual translations separately, for example using a plugin like Weglot.

0%