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
- What hreflang is and what it does
- Hreflang syntax and examples
- Language and region codes
- The self-referencing rule and return links
- x-default: what it is for
- Hreflang and canonical tags
- Hreflang in the XML sitemap
- Hreflang on WordPress, Shopify, Webflow and Next.js
- Common hreflang mistakes and how to fix them
- How to check hreflang
- When you do not need hreflang
- 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.
| Method | Where it goes | Example |
|---|---|---|
| HTML link element | In the head of every version | <link rel=”alternate” hreflang=”en-gb” href=”https://example.com/uk/” /> |
| HTTP header | In 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 sitemap | One <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).
| Code | Means | Note |
|---|---|---|
| en | English, any country | Use with an en-us or en-gb pair when the versions differ by country |
| en-gb | English, United Kingdom | Not en-uk |
| en-us | English, United States | Pair with en-gb, en-ca, en-au as needed |
| de | German, any country | Add de-at, de-ch only when the versions genuinely differ |
| fr-ca | French, Canada | Distinct from fr (France and elsewhere) |
| es-419 | Spanish, Latin America | UN M.49 region code, accepted by Google |
| pt-br | Portuguese, Brazil | Distinct from pt-pt |
| zh-hans / zh-hant | Chinese, simplified or traditional script | Script subtags are accepted; add a region if needed (zh-hant-tw) |
| x-default | Fallback for unmatched searchers | Usually the global or language-selector page |
The self-referencing rule and return links
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
| Error | What you see | Fix |
|---|---|---|
| No self-referencing hreflang | Set ignored on that page; wrong version ranks | Add the page’s own URL to its set; generate sets from one source |
| Missing return links | Alternates listed but not reciprocated | Regenerate on every sibling; verify with the checker after deployment |
| Invalid codes | en-uk, region-only codes, made-up regions | Use ISO 639-1 + ISO 3166-1 Alpha-2 (en-gb); es-419 is the accepted exception |
| Hreflang to non-canonical URL | Country page canonical to home page; hreflang ignored | Make each version canonical to itself; list canonical URLs only |
| Alternate returns non-200 | Redirects, 404s or IP-based redirects in the set | List final URLs only; remove IP redirects for Googlebot |
| Missing x-default | Fallback chosen by Google | Add one x-default per set pointing at a live page |
| Duplicate values in one set | Two URLs for en-gb | One URL per language-region per set |
| Hreflang on noindex pages | Set points at pages Google will not index | Remove noindex or remove the page from the set |
| Mixed methods | Head and sitemap disagree | Choose one method sitewide |
| Language switcher only | One URL, content changes by JavaScript | Give 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.
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
- International SEO agency
- SEO company Las Vegas
- Texas SEO company
- SERPRobot review
- Ranktracker review
- Nightwatch review
- SEO company in Dallas
- SEO company in Oakland
- SEO company in Denver
- SEO company in Houston
- SEO company in Charlotte
- SEO companies by city
- Web design companies by city
- SEO company in Hawaii
- SEO for HVAC services
- Statewide SEO services
- Small business SEO
- SEO experts
- SEO pros and cons
- What is corporate SEO?
- Does URL length affect SEO?
- Meta description length
- SEO services
- SEO agency
- What are SEO services?
- What is SEO?
- Buyer personas
- Retail market research
- Local SEO services
- Local search
- Claiming a business profile
- Local SEO vs national SEO
- SEO company in New Jersey
- SEO agency NYC
- Affordable SEO services
- SEO company in Iowa
- SEO company in Maine
- SEO company in Idaho
- SEO company in Kentucky
- SEO company in Alabama
- SEO company in Louisiana
- SEO company in Indiana
- SEO company in Arkansas
- SEO company in Delaware
- SEO company in Connecticut
- SEO company in Massachusetts
- SEO company in Colorado
- SEO company in Maryland
- SEO company in Minnesota
- SEO company in California
- Best SEO company for small business
- SEO audit service
- SEO packages and pricing
- SEO pricing guide
- How long does SEO take?
- How to rank higher on Google
- Website not showing up on Google
- Google Business Profile not showing up
- How to set up a Google Business Profile
- Why is my website not getting traffic?
- SEO content writing service
- Shopify SEO services
- How to get more Google reviews
- Google review removal
- SEO for dentists
- SEO for doctors
- SEO for roofers
- SEO for plumbers
- SEO for HVAC companies
- SEO for chiropractors
- SEO for therapists
- SEO for landscapers
- SEO for med spas
- Best rank tracking tools
- Pro Rank Tracker review
- SERPWatcher review
- SEO tools for small business
- Instagram SEO
- Saving Instagram drafts
- Checking Instagram interactions
- Instagram hashtags
- TikTok profile views
- Finding TikTok drafts
- Snapchat filters and Lenses
- Organic SEO services
- SEO company in Portland
- SEO company in Kent, WA
- Ecommerce SEO services
- Customer data platforms
- Selling on Target Plus
- SEO for fintech
- SEO company in Atlanta
- Search engine marketing agency
- SEO company in Illinois
- Fairfax SEO company
- Oregon SEO
- Medford SEO
- Bend SEO
- Springfield, Oregon SEO
- Oregon City SEO
- Bellevue SEO
- Video for local SEO
- SEO diagrams
- Boca Raton SEO company
- Winery SEO
- Seattle SEO companies
AI, AEO and what is changing
Paid media and lead generation
Websites and design
Choosing and working with an agency
Software and app development
Web development, platforms and hosting
Social, content and brand
By industry and by situation
Frequently asked questions
What is a hreflang tag?
Is hreflang a ranking factor?
What is self-referencing hreflang?
What does x-default mean?
What is the correct code for the UK?
Can I use hreflang with a language only, without a country?
How do hreflang and canonical work together?
Should hreflang go in the head or the sitemap?
How do I check hreflang tags?
Why does the wrong language show in Google?
Does Shopify or WordPress add hreflang automatically?
Do I need hreflang for one language in several countries?
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.
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.
