Skip to content

This guide answers: hreflang for multilingual sites: syntax and common errors

Hreflang for multilingual sites: syntax and common errors

Learn the strict hreflang syntax, three ways to implement it, the seven most common errors and how to fix them, plus how to validate your setup.

By Hannah Wells, Technical SEO, site performance and online stores
· 7 min read

Based on example.com · updated 

Hreflang for multilingual sites: syntax and common errors
FIG. 01 Photo Pexels / Pixabay

Short answer

Hreflang is an attribute that tells Google which localized variants of a page exist, so it can serve the right language or regional version to each user. The syntax is strict: IETF BCP 47 codes with a hyphen, absolute URLs, return links on every variant, and a canonical that agrees with the hreflang. Google treats it as a hint, not a directive, so a broken setup raises no error in Search Console. It is simply ignored.

Key points

  1. Hreflang is an HTML attribute that signals the localized variants of a page.
  2. <link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page/" /> The value follows the IETF BCP 47 standard.
  3. Google accepts three methods: HTML link tags, an XML sitemap, and HTTP headers.
  4. For each error: what you see in a crawl, the cause, and the fix.

What hreflang is and why use it

Hreflang is an HTML attribute that signals the localized variants of a page. According to Google Search Central, it lets Google serve the correct language version to users. The typical case is a site with English for the US, the UK and Australia (en-US, en-GB, en-AU). Another is a site with English, French and German versions.

Without it, Google may treat two close versions as duplicate content, dilute the signal between them, or show a user the wrong language. Hreflang gives the engine an explicit map of which page is the counterpart of which.

It is just as important to know what hreflang does not do. It does not force IP-based geolocation. It does not force a particular ranking. It does not replace a well-designed site structure. Google does not treat it as a ranking factor: it is a hint about which version fits which audience.

That is also why so many setups go unnoticed. Roughly 75 % of implementations contain at least one error, according to CognitiveSEO and a DEV Community article on hreflang mistakes. Because Google ignores a broken tag quietly, nothing warns you.

Syntax: the IETF BCP 47 format

The base structure is an alternate link carrying a language-region value and an absolute URL:

<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page/" />

The value follows the IETF BCP 47 standard. Three rules matter:

  • The language is an ISO 639-1 code in lowercase: en, de, fr, ja, zh.
  • The optional region is an ISO 3166-1 alpha-2 code in uppercase: US, GB, DE, AT, CA.
  • The separator is a hyphen. An underscore invalidates the attribute.

The language alone is valid (en, de, fr, ja). So is language plus region (en-US, en-GB, de-AT, fr-CA). Here is how valid and invalid values compare:

Valid Invalid Why it fails
en english A language name is not a code
en-US en_US Underscore instead of a hyphen
en-GB en-uk The United Kingdom is GB, not UK
en-AU, de-DE, de-AT, de-CH Language plus region, correct form

The special value x-default designates the fallback version. It serves users whose language or region matches none of the other declared variants. A typical choice is a language selector page or your main international version:

<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Three ways to implement hreflang

Google accepts three methods: HTML link tags, an XML sitemap, and HTTP headers. Pick one and keep it consistent.

HTML link tags

Place the tags in the <head> of every variant. Each page lists all variants, itself included. Here is a complete example for a three-language site:

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

The same block appears on the English, French and German pages. That is what satisfies both self-reference and return links.

XML sitemap

The sitemap uses an xhtml:link element for each variant, inside the entry of each URL:

<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/page/" />

The main advantage is centralized maintenance: one file to update instead of every page template.

HTTP header

The Link header carries the same information at the server level. Its use case is non-HTML files, such as multilingual PDFs, which have no <head> to hold tags.

Which one to choose

The comparison below gives a verdict by profile. We list no prices, because none of these methods is a product you buy.

  • Small site with templates you control: HTML link tags. They are visible in the page source and easy to check.
  • Large site with many variants: the XML sitemap. It keeps the annotations in one place and keeps the HTML lighter.
  • Site serving PDFs or other non-HTML files: HTTP headers, the only method that fits those files.
  • Avoid: mixing methods without a reason. Contradictory declarations are hard to debug.

Each method has limits. Tags add weight to every page. Headers are invisible in the page source and need server access to inspect. The sitemap is not visible on the page at all.

The seven most common errors and their fixes

For each error: what you see in a crawl, the cause, and the fix.

Missing self-reference

Each page must point to itself with hreflang as well as to its variants. The symptom in a crawl is a page whose block lists only the other languages. The fix is to add the page’s own URL and code to the block.

Invalid language or region codes

The most frequent slips are “english” instead of en, en_US instead of en-US, and en-uk instead of en-gb. The cause is usually a guess at the format instead of a check against the standards. Replace each value with a valid BCP 47 code, using GB for the United Kingdom.

Broken bidirectionality

Page A points to page B, but B has no link back to A. The absence of a return link breaks or weakens the signal. A crawl shows pairs where only one side declares the relationship. Add the missing return annotation on the other variant.

Canonical and hreflang in contradiction

If the /fr/ page has a canonical pointing to /en/, the canonical takes priority and the hreflang is ignored. The canonical and the self-referencing hreflang must point to the same URL. Align them on every variant.

Non-absolute or inaccessible URLs

A value such as page.html is not enough: use https://example.com/fr/page.html. Targeted URLs must return status 200 and be indexable. A URL returning 404 or 301 is a defect. Fix the path or point to the final destination.

No x-default declared

Take an Italian visitor on a site offering English, French and German. No variant matches. Declare x-default on every variant, pointing to the version you want as the fallback, usually the main international page or a language selector.

Redirect after hreflang

The hreflang points to https://example.com/de/, which redirects to https://de.example.com/. The signal is weakened. Put the final URL in the annotation, the one that answers directly.

Validation and testing

Because Google silently ignores broken hreflang, you have to test it yourself.

  • Free tools: CMS plugins and free SEO tools can extract the hreflang annotations from a URL.
  • Search Console: it has an International Targeting section, but remember that a broken implementation raises no error there.
  • Crawlers: Screaming Frog, Ahrefs and Sitebulb let you check annotations across a whole site. We give no pricing for them, as none is established here; check each vendor’s own page.
  • Command line: a simple curl piped to grep confirms the attribute is present in the delivered HTML.

Before launch, run through this checklist:

  • Each variant points to itself.
  • Each variant points to all the others (bidirectionality).
  • The codes are valid BCP 47.
  • URLs are absolute, return 200 and do not redirect.
  • The canonical matches the hreflang self-reference.
  • x-default is declared and consistent.
  • The attribute is present in the delivered source.

Review the setup after a migration, after adding a language, and after any change of site architecture.

Edge cases and advanced traps

Subdomains (en.example.com, fr.example.com) and subdirectories (/en/, /fr/) work identically with hreflang. The traps differ: with subdomains, watch for inconsistency between the www and non-www hosts in the URLs you declare.

On single-page applications and JavaScript-heavy sites, the annotations must be parsable. Server-rendered output is the safer place for them than client-side injection.

For gated content, such as paywalls or login-required pages, decide whether the hreflang targets the logged-in page or the public one. Google does not document the exact behavior for deliberate duplicate content across entry pages, so we make no claim about it.

What Google says officially

Google describes hreflang as a hint, not a directive. In practice: no direct ranking effect and no penalty when it is broken. Google may index a default version and the variants it notices even without a flawless setup. Hreflang does not improve your ranking, and it is not a ranking factor.

Questions people ask

Can hreflang be used for content variants such as AMP versus non-AMP, or PDF versus HTML?

Yes, but it is a different use case from language targeting. For PDFs, the HTTP header method applies.

Do I need hreflang on each variant if I already use rel=alternate-canonical?

Yes. Hreflang replaces that older method.

Does hreflang affect crawl budget?

Only indirectly: Google can crawl more intelligently. There is no direct effect.

Sources consulted on 03/12/2026: Google Search Central (Localized versions of your pages), CognitiveSEO, DEV Community, Nautilinks, Ighenatt, Clear Click, ConveyThis, IETF RFC 5646, ISO 639-1 and ISO 3166-1 alpha-2.

Read next in Technical SEO

seo-service-journal technical-seo

How Google crawls a website: crawl budget, crawl rate and what slows it down

· 8 min read

seo-service-journal technical-seo

Indexing explained: why a page is crawled but not indexed

· 8 min read

seo-service-journal technical-seo

Robots.txt: syntax, common mistakes and how to test it

· 6 min read

Free newsletter · every Monday

The Monday Crawl

One email each Monday: what changed in the official search documentation, and what to check on your own site.

Free. One click to unsubscribe. We use your email only to send the newsletter. Privacy policy.