Hreflang Tags
Hreflang tags are link annotations in HTML, HTTP headers or XML sitemaps that map each page to its language and regional versions for search engines.
What are Hreflang Tags?
Hreflang tags are the annotations that tell search engines which language and regional versions of a page exist and which locale each one targets. They can be placed as <link rel="alternate" hreflang="..."> elements in the HTML head, as Link HTTP headers or as xhtml:link entries in an XML sitemap. Google uses them to serve the right version to each user.
The underlying concept is covered in the hreflang entry. This page focuses on implementation choices and errors.
How it works
Three implementation methods:
| Method | Best for | Watch out for |
|---|---|---|
HTML <link> in head | Small to mid-size sites | Adds weight to every page |
HTTP Link header | PDFs and non-HTML files | Harder to audit |
| XML sitemap | Large multilingual sites | Sitemap must stay in sync |
XML sitemap example:
<url>
<loc>https://example.com/us/pricing</loc>
<xhtml:link rel="alternate" hreflang="en-us"
href="https://example.com/us/pricing"/>
<xhtml:link rel="alternate" hreflang="de"
href="https://example.com/de/preise"/>
</url>
Each URL in the set must list every alternate, including itself, and every alternate must link back.
Examples
- A SaaS company with 6 locales and 2,000 pages moves hreflang from HTML into its sitemap generator, removing thousands of lines of markup from page templates.
- A security vendor publishes German and French versions of its compliance whitepaper as PDFs and adds hreflang via HTTP headers.
- An audit finds
hreflang="en-uk"across a site. Correcting it toen-gbmakes the annotations valid.
Best practices
- Generate hreflang automatically from a single source of truth for page equivalents.
- Use absolute, canonical, indexable URLs that return 200.
- Add
x-defaultfor unmatched users. - Validate after every release that touches templates, URLs or locales.
- Document which method you use so developers do not add a second one.
Common mistakes
- Missing return links (A references B, but B does not reference A).
- Invalid codes, such as “en-uk”, “jp” for Japanese (should be “ja”) or region without language.
- Annotations pointing to redirected URLs after a migration.
- A canonical tag pointing to another language version.
How to audit hreflang tags
A practical audit takes four passes:
- Crawl the site with hreflang extraction enabled and export every annotation.
- Validate codes against ISO 639-1 language and ISO 3166-1 region lists.
- Check reciprocity: every pair must reference each other, and each page must reference itself.
- Cross-check status and canonicals: every target should return 200, be indexable and be self-canonical.
Then confirm the outcome in Search Console by filtering performance by country and checking which URL earns impressions in each market. If the wrong locale still dominates, look for conflicting signals such as internal links that point only to one version.
Related terms
- Hreflang
- XML Sitemaps
- Language Targeting
- Canonical Tags
- Subdirectories for Regional Sites
- Hreflang Tag
Sources
- Tell Google about localized versions of your page, Google Search Central
- Managing multi-regional and multilingual sites, Google Search Central
- URL Inspection tool, Search Console Help
Frequently asked questions
Which hreflang implementation method is best?
All three are supported by Google. HTML link elements are easy for small sites. XML sitemaps keep page code light and are easier to manage at scale. HTTP headers are mainly for non-HTML files like PDFs. Use one method consistently rather than mixing them for the same URLs.
How do I check if my hreflang tags are working?
Crawl the site with a tool like Screaming Frog to validate return links, codes and canonical conflicts. Use Search Console's URL Inspection to confirm Google's chosen canonical, and check performance by country to see whether the right version gets impressions in each market.
Do hreflang tags need to point to absolute URLs?
Yes. Google requires fully qualified URLs, including the protocol, such as https://example.com/de/. Relative URLs are a common cause of hreflang errors. Each URL should also return a 200 status, be indexable and match its own canonical tag. Pointing hreflang at redirects, noindexed pages or non-canonical variants causes Google to ignore those annotations.