Skip to main content Scroll Top

Hreflang Tags: Guide, Free Checker and Generator (Self-Referencing, x-default, Canonical, Sitemap)

Updated September 2026 · Written and maintained by the Progression Agency strategy team

Hreflang is the attribute that tells Google which language or country version of a page to show to which searcher. This guide covers what it does, the exact syntax for HTML, HTTP headers and XML sitemaps, the language and region codes, the self-referencing and return-link rules, x-default, how hreflang interacts with canonical tags, platform notes for WordPress, Shopify, Webflow and Next.js, and the errors that break it. A free checker and a tag generator are on the page.

On this page · 12 sections
  1. What hreflang is and what it does
  2. Hreflang syntax and examples
  3. Language and region codes
  4. The self-referencing rule and return links
  5. x-default: what it is for
  6. Hreflang and canonical tags
  7. Hreflang in the XML sitemap
  8. Hreflang on WordPress, Shopify, Webflow and Next.js
  9. Common hreflang mistakes and how to fix them
  10. How to check hreflang
  11. When you do not need hreflang
  12. Getting hreflang fixed

The short answerHreflang is a hint, not a ranking factor: it does not make a page rank, it decides which of your equivalent pages Google shows in a given country or language once one of them ranks. It works only when every version lists every version including itself, every link is returned, the codes are valid ISO codes, the URLs are canonical and return 200, and an x-default covers everyone else. Most hreflang problems are one of those five rules broken on some pages but not others. Use the checker below on a page, fix what it lists, and re-check after deployment.

Rules on this page follow Google’s published documentation as linked in the text. The checker reads HTML link elements only and does not read HTTP headers or sitemaps; it fetches at most eight alternates per check and is rate-limited.

What hreflang is and what it does

Hreflang is an attribute on a link element (or an equivalent HTTP header or sitemap entry) that declares the language, and optionally the region, of an alternate version of the current page. Google uses it to show the German version to searchers in Germany and the English version elsewhere, instead of choosing by guesswork. Google’s documentation on localized versions of a page is the source of every rule on this page. Hreflang does not translate, does not redirect and does not boost rankings; it is a cross-reference between pages that already exist.

Hreflang checker

Enter a page URL. The checker reads the hreflang link elements in the page’s HTML, tests the self-reference and x-default rules, checks the canonical, and fetches up to eight alternate URLs to confirm they return HTTP 200 and link back.

Hreflang tag generator

One line per version: a language or language-region code, a space, then the URL. Include an x-default line. The generator returns the link elements to place in the head of every listed page, and the equivalent XML sitemap block.

Hreflang syntax and examples

Google accepts three methods. Use one consistently; mixing them on the same site makes debugging harder. HTML link elements in the head are the most common; HTTP headers are for non-HTML files such as PDFs; the XML sitemap method is the easiest to maintain at scale because the whole set is generated from data.

Three ways to declare hreflang
MethodWhere it goesExample
HTML link elementIn the head of every version<link rel=”alternate” hreflang=”en-gb” href=”https://example.com/uk/” />
HTTP headerIn the response headers of every version (required for PDFs and other non-HTML files)Link: <https://example.com/uk/>; rel=”alternate”; hreflang=”en-gb”
XML sitemapOne <url> entry per version, each listing every alternate as an xhtml:link<xhtml:link rel=”alternate” hreflang=”de” href=”https://example.com/de/” />

Language and region codes

The language is an ISO 639-1 two-letter code (en, de, fr, es, pt, ja, zh). The optional region is an ISO 3166-1 Alpha-2 country code (us, gb, de, ca, au, br) written after a hyphen. Region alone is not valid: hreflang=”gb” is an error, hreflang=”en-gb” is correct. The one common exception is a UN M.49 region code such as es-419 for Latin American Spanish. Codes are case-insensitive but conventionally lower-case language and upper-case region (en-GB); the checker on this page normalises case. The most frequent code mistakes are en-uk (the country code is gb), using a three-letter language code where the two-letter one exists, and inventing region codes (eu is not a valid region for Europe).

Common hreflang codes
CodeMeansNote
enEnglish, any countryUse with an en-us or en-gb pair when the versions differ by country
en-gbEnglish, United KingdomNot en-uk
en-usEnglish, United StatesPair with en-gb, en-ca, en-au as needed
deGerman, any countryAdd de-at, de-ch only when the versions genuinely differ
fr-caFrench, CanadaDistinct from fr (France and elsewhere)
es-419Spanish, Latin AmericaUN M.49 region code, accepted by Google
pt-brPortuguese, BrazilDistinct from pt-pt
zh-hans / zh-hantChinese, simplified or traditional scriptScript subtags are accepted; add a region if needed (zh-hant-tw)
x-defaultFallback for unmatched searchersUsually the global or language-selector page

Each version must include a link to itself in its hreflang set, and every page named in the set must name this page back. Google ignores a hreflang set whose links are not reciprocated, which is why a site can have hreflang on every page and still show the wrong versions. The practical consequence is that hreflang cannot be maintained page by page: it has to be generated from a single source of truth (the CMS’s language relationships or a sitemap generator) so that adding a version updates every sibling. The checker on this page fetches the alternates and reports missing return links; a missing self-reference is the most common single finding.

x-default: what it is for

x-default marks the page to show when no listed language or region matches the searcher, typically the global English page or a language-selector page. It is not required, but without it Google picks a fallback itself. Use exactly one x-default per set, point it at a real page that returns 200, and do not point it at an IP-based redirect, which Googlebot (crawling from the US) cannot follow to other versions.

Hreflang and canonical tags

Hreflang and canonical must agree. Each version should be canonical to itself; the hreflang URLs must be the canonical URLs. A country page that canonicalises to the home-market page is telling Google to treat it as a duplicate, and Google then ignores its hreflang, which produces the classic symptom of the home version ranking everywhere. Google’s guidance on consolidating duplicate URLs explains why: canonical is a consolidation signal, hreflang is a targeting signal, and consolidation wins. The checker reports a canonical that points elsewhere as a finding.

Hreflang in the XML sitemap

In the sitemap method each URL entry lists every alternate, including itself, as an xhtml:link element, and the urlset declares the xhtml namespace. The set must be repeated under each version’s own entry, which is why generating the sitemap from data is the sane approach for sites with more than a handful of pages. Google’s sitemap documentation covers the format; the generator above produces one entry’s block. Keep lastmod accurate or omit it; a lastmod that changes on every build teaches Google to ignore it.

Hreflang on WordPress, Shopify, Webflow and Next.js

On WordPress, multilingual plugins such as WPML and Polylang emit hreflang for the language relationships you define; the errors we see are pages left untranslated but still published, and x-default missing because the setting was never enabled. Shopify emits hreflang automatically for markets configured under Shopify Markets, whether on subfolders or separate domains; problems come from custom domains that were not linked as markets. Webflow’s Localization feature emits hreflang for locales you publish; check that each locale’s pages are actually published, not only created. In Next.js, the metadata API’s alternates.languages field generates the link elements per route; the frequent mistake is a static set that omits the current route’s own URL. Whatever the platform, run the checker after each change rather than trusting the setting.

Common hreflang mistakes and how to fix them

Hreflang errors, symptoms and fixes
ErrorWhat you seeFix
No self-referencing hreflangSet ignored on that page; wrong version ranksAdd the page’s own URL to its set; generate sets from one source
Missing return linksAlternates listed but not reciprocatedRegenerate on every sibling; verify with the checker after deployment
Invalid codesen-uk, region-only codes, made-up regionsUse ISO 639-1 + ISO 3166-1 Alpha-2 (en-gb); es-419 is the accepted exception
Hreflang to non-canonical URLCountry page canonical to home page; hreflang ignoredMake each version canonical to itself; list canonical URLs only
Alternate returns non-200Redirects, 404s or IP-based redirects in the setList final URLs only; remove IP redirects for Googlebot
Missing x-defaultFallback chosen by GoogleAdd one x-default per set pointing at a live page
Duplicate values in one setTwo URLs for en-gbOne URL per language-region per set
Hreflang on noindex pagesSet points at pages Google will not indexRemove noindex or remove the page from the set
Mixed methodsHead and sitemap disagreeChoose one method sitewide
Language switcher onlyOne URL, content changes by JavaScriptGive each language its own URL

How to check hreflang

For one page, use the checker at the top of this page: it reads the HTML link elements, validates codes, tests self-reference, x-default and canonical, and fetches alternates to confirm return links. For a whole site, crawl it with a desktop crawler that reports hreflang (Screaming Frog’s hreflang report is the standard) and cross-check the sitemap. Search Console’s international targeting report was retired, so the crawl and the checker are the verification. Re-check after every deployment that touches templates or language settings.

Ranking in more than one country?Send the site and the markets. We reply with a written view of the URL structure, the hreflang state and what an international SEO engagement would cost.

Request an international SEO review

When you do not need hreflang

A site in one language for one country does not need hreflang, and adding it does nothing. A site in one language sold in several countries with identical pages does not need it either unless the pages differ (prices, spellings, contact details); if they differ, it does. If you are deciding whether to create country versions at all, that is an international SEO question rather than a hreflang one, and it comes first.

Getting hreflang fixed

Progression Agency fixes hreflang as a scoped, fixed-price job and runs international SEO for sites that serve several countries, from New York City for clients across the United States and worldwide. Run the checker, send us the findings, and you get a written scope.

Getting found in search

Frequently asked questions

What is a hreflang tag?
A link element (or HTTP header or sitemap entry) that declares the language and optionally the country of an alternate version of the page, so Google can show the right version to the right searcher.
Is hreflang a ranking factor?
No. It does not make pages rank; it decides which of your equivalent pages is shown once one of them ranks in a country or language.
What is self-referencing hreflang?
Each page’s hreflang set must include the page’s own URL. A set without the self-reference is ignored by Google.
What does x-default mean?
The version to show searchers who match none of the listed languages or regions, usually the global page or a language selector. Use one per set.
What is the correct code for the UK?
en-gb. The country code for the United Kingdom is GB under ISO 3166-1; en-uk is invalid.
Can I use hreflang with a language only, without a country?
Yes. hreflang=”de” targets German speakers in any country. Add a region (de-at) only when versions genuinely differ by country.
How do hreflang and canonical work together?
Each version must be canonical to itself and the hreflang URLs must be the canonical URLs. A version that canonicalises to another page has its hreflang ignored.
Should hreflang go in the head or the sitemap?
Either works; use one method sitewide. Sitemaps are easier to generate and maintain at scale; head tags are simpler for small sites. HTTP headers are for non-HTML files.
How do I check hreflang tags?
Use the checker on this page for a single URL; crawl the site with a tool that reports hreflang for a whole site; re-check after every deployment.
Why does the wrong language show in Google?
Usually one of: missing self-reference or return links, a canonical pointing to another version, invalid codes, alternates that redirect or 404, or all languages on one URL with a JavaScript switcher.
Does Shopify or WordPress add hreflang automatically?
Shopify adds it for markets configured in Shopify Markets; WordPress adds it through multilingual plugins such as WPML or Polylang; Webflow through Localization; Next.js through the metadata API. Verify the output rather than trusting the setting.
Do I need hreflang for one language in several countries?
Only if the pages differ by country (prices, spellings, contact details). Identical pages need no hreflang.

Ranking in more than one country?Send the site and the markets. We reply with a written view of the URL structure, the hreflang state and what an international SEO engagement would cost.

Request an international SEO review

Get a free marketing proposal

Tell us what you are trying to grow and we will come back with a plan, not a pitch deck. Same-day reply on weekdays.

Privacy Preferences
When you visit our website, it may store information through your browser from specific services, usually in form of cookies. Here you can change your privacy preferences. Please note that blocking some types of cookies may impact your experience on our website and the services we offer.
Contact Us
0