Skip to content
Search

Hreflang tag: what it is and how it works

The hreflang tag tells search engines which language and regional version of a page should be shown to users; it helps engines choose the correct variant for indexation and serving, but it does not by itself determine rank.

Hreflang Tag: Guide for Multilingual Websites

Overview

Hreflang is an HTML/hyperlink signal you add to pages, HTTP headers, or XML sitemaps to declare language and optional regional targeting for alternate URLs. Search engines use hreflang to pick the most appropriate localized URL to surface for a user in a particular language or region. Hreflang affects which variant a search engine indexes and displays for queries in that language or locale; it is not a direct ranking signal that alone determines ordering in search results.

Key points at a glance: hreflang entries must be consistent across variants, include a self-referential link, use correct language-region codes (ISO 639-1 / ISO 3166-1), and be applied to the version the crawler uses for indexing โ€” for Google that means the mobile version is the primary basis (Google crawls with Googlebot Smartphone by default since July 2024).

Step-by-step

Use these steps to add hreflang reliably.

1) Choose your codes and canonical strategy

Decide whether to use language-only codes (for example "en"), language-region codes (for example "en-GB"), or both. Keep canonical and hreflang consistent: each localized page can have a self-referential hreflang and its own canonical; do not point hreflang to a canonical that differs in language.

2) Choose placement: link element, HTTP header, or XML sitemap

There are three common ways to declare hreflang. Each has tradeoffs:

- HTML <link> elements in the <head> โ€” pros: simple, easy to audit in source; cons: requires identical head on all device versions (ensure mobile parity). Example: <link rel="alternate" hreflang="en" href="https://example.com/en/">

- HTTP headers โ€” pros: useful for non-HTML files (PDFs); cons: harder to manage and audit. Example header: Link: <https://example.com/fr/>; rel="alternate"; hreflang="fr"

- XML sitemaps with <xhtml:link> entries โ€” pros: centralised for large sites and sitewide variants; cons: must maintain accurate URLs and ensure sitemap is accessible to crawlers.

3) Implement a full bi-directional set (reciprocity)

Every alternative URL you list must also list every other alternative (including the source) back. For example, page A lists A, B and C; page B must list A, B and C; page C must list A, B and C. Reciprocity reduces ambiguity for crawlers and helps correct variant selection.

Common problems

Typical implementation errors to watch for and how they affect indexation and serving.

- Wrong or inconsistent codes (mixing en and en-US) โ€” can cause search engines to ignore entries or choose a different variant.

- Missing self-referential tag โ€” if a page does not include itself in the list, reciprocity fails and alternate selection can be incorrect.

- Non-indexable or blocked pages (noindex, robots disallow) โ€” an alternate that is not indexable is usually less useful; search engines may ignore it when constructing variant sets.

- Mixing relative and absolute URLs, or HTTP/HTTPS mismatch โ€” use absolute, canonicalized URLs that match the version crawlers access.

How to verify and troubleshoot

Verification differs depending on whether you own the site or are auditing a third-party. For pages you own use Google Search Console URL Inspection to see how Google indexed the page and which variant it chose. For any site, use HTTP and rendered checks with common tools below.

Tools and commands

Chrome DevTools (View Source and Elements) โ€” verify the <link rel="alternate" hreflang="..."> entries are present in the served HTML and visible on the mobile-responsible page.

curl -I https://example.com/path/ โ€” shows response headers only (useful to check server headers and link headers).

curl https://example.com/path/ โ€” fetches the HTML body; use curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/path/ to see what the server returns to a Googlebot user-agent (do not use this to cloak โ€” only to audit how the server responds).

Bing Webmaster Tools Site Explorer โ€” check crawl behaviour and index signals for Bing.

Note: URL Inspection in Google Search Console is authoritative for pages you own; for third-party pages you must rely on public fetches and indexation signals such as site: queries (which are indicative, not definitive).

Practical checklist

- **Hreflang present on canonical/mobile version** โ€” where to verify: view-source or curl as mobile UA โ€” passes when all variants list the same set of hreflang entries.
- **Self-referential entry** โ€” where to verify: page source โ€” passes when the current URL appears in the set.
- **Reciprocity across variants** โ€” where to verify: check each variant's source or sitemap โ€” passes when every variant lists every alternative.
- **Indexability of alternates** โ€” where to verify: URL Inspection (own site) or site: operator and public fetch โ€” passes when alternates are crawlable and not blocked by robots or noindex.
- **URL canonical and protocol parity** โ€” where to verify: HTTP headers and canonical link โ€” passes when hreflang href values match canonical and use the same scheme (https/http) that users and crawlers reach.
- **x-default for fallback** โ€” where to verify: page source or sitemap โ€” passes when a sensible fallback (homepage or language selector landing) is marked with hreflang="x-default".

Before the FAQ: if you want a deeper technical reference, see Read the Technical SEO Guide

Frequently asked questions

Does hreflang improve rankings?

Hreflang helps search engines serve the appropriate language/region variant and can reduce duplicate-content confusion, but it is not a standalone ranking boost. Many ranking signals are involved in ordering results.

When should I use hreflang vs separate country sites?

Use hreflang when you have language or regional variants of substantially similar content hosted on different URLs (subdirectories, subdomains, or ccTLDs). Separate country sites are appropriate when content and business rules differ significantly by market.

Do I need an x-default tag?

x-default is recommended for ambiguous cases (for example a language selector landing page) so search engines have a clear fallback when no precise language match exists.

Can hreflang be used with canonical tags?

Yes. Each localized page can have a canonical pointing to itself and include hreflang entries listing other localized versions. Avoid pointing hreflang to a canonical that represents a different language variant.

Final note: hreflang helps indexation and variant selection but must be implemented and maintained consistently; regular audits with browser DevTools, curl, and Search Console (for your own site) are the most reliable way to catch regressions.

Build authority with quality backlinks. Technical SEO and correct international targeting are essential parts of organic growth; authority from relevant, indexable placements complements a correct hreflang setup and helps users discover the right variant.

Related terms