Hreflang is one of those technical SEO implementations that sounds simple, executes messily, and causes disproportionate ranking damage when done wrong. International businesses regularly lose significant organic traffic to hreflang errors — wrong language codes, missing return tags, broken clusters — that a proper implementation would have prevented entirely. This guide gives you a complete, technically accurate framework for hreflang implementation: the syntax, the edge cases, the CMS-specific approaches, and the testing methodology to verify it’s actually working.
What Hreflang Is (and What It Isn’t)
Hreflang is an HTML attribute that communicates language and regional targeting to search engines — primarily Google and Yandex. It solves a specific problem: when you have multiple versions of the same content for different languages or regions, search engines need to know which version to serve to which users, and how these versions relate to each other.
The Problem Hreflang Solves
Without hreflang, Google sees your English (US), English (UK), English (Australia), and English (Canada) pages as near-duplicate content. It doesn’t know which version to rank where. The result is ranking cannibalization: your pages compete against each other, ranking signals are diluted, and users in Australia might get served your US page. Hreflang explicitly tells Google: “These pages are intentional regional variants. Show this one to users in Australia, this one to users in the UK.”
What hreflang does NOT do: it’s not a ranking factor that boosts rankings. It doesn’t fix thin content. It doesn’t create international presence where none exists. It organizes and protects your existing international SEO structure — it doesn’t build it from scratch.
How Google Uses Hreflang Signals
Google treats hreflang as a hint, not a directive. If your hreflang implementation is clean and consistent, Google follows it. If it’s inconsistent or contains errors, Google may ignore it and make its own language/region determinations. This is why precision matters — a partially broken hreflang implementation is often worse than no implementation, because it creates conflicting signals.
Hreflang Syntax: Getting It Right
The syntax is straightforward. Most errors come from carelessness rather than misunderstanding.
Basic HTML Implementation
Hreflang tags go in the <head> section of every page in the cluster. Each page must contain self-referencing tags AND tags for every alternate version:
<!-- On the US English page -->
<link rel="alternate" hreflang="en-US" href="https://www.example.com/en-us/page/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/en-gb/page/" />
<link rel="alternate" hreflang="en-AU" href="https://www.example.com/en-au/page/" />
<link rel="alternate" hreflang="de" href="https://www.example.com/de/page/" />
<link rel="alternate" hreflang="fr" href="https://www.example.com/fr/page/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/page/" />
The same set of tags appears on every page in the cluster. On the German page, the same 6 tags appear — just with different absolute URLs. Every page points to all the others. This is the “return tag” requirement, and it’s the most commonly violated hreflang rule.
Language and Country Codes
Use ISO 639-1 for language codes (2-letter lowercase) and ISO 3166-1 alpha-2 for country codes (2-letter uppercase). Combined: en-GB, zh-TW, pt-BR. Common mistakes:
- ❌
en-uk— country code must be uppercase:en-GB - ❌
EN-gb— language code must be lowercase:en-GB - ❌
english— use ISO codes, not full language names - ❌
zh-CNwhen you mean traditional Chinese for Taiwan —zh-TW - ❌
en-EU— EU is not a valid country code in ISO 3166-1
Language-only targeting (no country) is valid and often preferable: hreflang="de" targets German speakers globally, not just Germany. Use language+country combinations only when you have genuinely different content for the same language in different regions.
The x-default Tag
The x-default tag specifies the fallback page for users who don’t match any language/region in your cluster. Always include it. Typically point it to your international/English page or your homepage. Without it, Google has no fallback instruction for users outside your targeted regions.
The 7 Most Common Hreflang Errors
These are the errors that appear in nearly every international site audit. Learn them, check for them, fix them.
Error 1: Missing Return Tags
The most common error. Every page in a hreflang cluster must contain tags pointing to ALL other pages in the cluster, including itself. If your English page references your German page, the German page MUST reference the English page back. Missing return tags cause Google to ignore the entire cluster for the pages with incomplete tags.
At scale, this breaks when content teams add new language versions without updating existing pages. The fix: generate hreflang tags dynamically from a centralized language-URL mapping, not manually per page.
Error 2: Hreflang on Non-Canonical Pages
Only canonical pages should appear in hreflang clusters. If a page has a rel="canonical" pointing to a different URL, that page should not be in a hreflang cluster. Google expects hreflang URLs to be canonical — including paginated pages, parameter-based URL variants, or session-ID URLs. Audit your hreflang clusters against your canonical structure regularly.
Error 3: Mismatched URLs Across Implementation Methods
If you implement hreflang in both HTML and XML sitemap, the URLs must match exactly. https://example.com/de/ and https://www.example.com/de/ are different URLs to Google’s crawler. HTTP and HTTPS are different. Trailing slash vs. no trailing slash may be different. Standardize on one URL format across your entire implementation.
Error 4: Broken Hreflang URLs
Hreflang URLs must return 200 status codes. A hreflang tag pointing to a 301, 404, or 410 is a broken signal. This happens commonly when content is deleted or URLs change without updating hreflang implementation. Audit for broken hreflang URLs quarterly — especially after any site migration or CMS change.
Error 5: Including Non-Existent Language Versions
Don’t create hreflang tags for language versions that don’t have real, translated content. Machine-translated thin content with hreflang signals is worse than no international targeting — it signals manipulation to Google and provides no value to users. If you don’t have real German content, don’t tag German targeting.
Error 6: Inconsistent HTTP/HTTPS Protocol
Sites migrating from HTTP to HTTPS frequently create hreflang clusters that mix protocols. All URLs in your hreflang cluster should use your canonical protocol (HTTPS). Any HTTP URLs in hreflang tags need to be updated to HTTPS after a migration.
Error 7: Overlooking Pagination
Category pages, blog archives, and product listings often have pagination. International sites need hreflang on every paginated page, pointing to the paginated equivalents in each language — not the first page of the paginated series. Paginated pages serve different content; they need their own hreflang clusters. This is frequently missed and causes incorrect page serving for paginated international content.
Implementation Methods: HTML vs. HTTP Headers vs. XML Sitemap
Google accepts hreflang implementation through three methods. Each has appropriate use cases.
HTML Head Implementation
Best for: most sites, especially those with under 1,000 pages per language. Easiest to implement, easiest to debug with browser tools. Implemented directly in the <head> section of each page. The standard choice for WordPress, Shopify, and most CMS platforms.
HTTP Header Implementation
Required for non-HTML files (PDFs, documents). Add hreflang via HTTP response headers when the file itself can’t contain HTML. For PDF documentation with language variants, this is the only valid method. Implement via server configuration (nginx, Apache) or CDN header rules.
# Nginx example for PDF files
location ~* \.pdf$ {
add_header Link '<https://example.com/de/doc.pdf>; rel="alternate"; hreflang="de", <https://example.com/en/doc.pdf>; rel="alternate"; hreflang="en"';
}
XML Sitemap Implementation
Best for: large sites (1,000+ URLs per language) where per-page HTML tags would be complex to maintain. Create a sitemap that uses the hreflang sitemap extension:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.example.com/en/page/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/page/"/>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/page/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://www.example.com/page/"/>
</url>
</urlset>
Choose one method and use it consistently. Implementing all three simultaneously creates redundancy without benefit and makes debugging harder.
CMS Implementation Guides
The theory is straightforward. Execution varies by platform.
WordPress
Yoast SEO (Premium) handles hreflang through its multilingual module. WPML (WordPress Multilingual Plugin) generates hreflang automatically across translated content. Polylang also handles hreflang generation. Manual implementation via functions.php works but requires developer maintenance. For any serious international WordPress site, WPML + Yoast is the production-grade stack — both are battle-tested on high-traffic international sites. This integrates with broader WordPress SEO best practices.
Shopify
Shopify Markets with international domains handles hreflang automatically when set up correctly. The key: configure separate domains or subdomains per market, not query parameters. Shopify’s hreflang generation is reliable when Markets is configured properly, but breaks when stores use manual language switching without proper Markets setup. Check your implementation with Screaming Frog after any Markets configuration change.
Headless CMS and Custom Implementations
For headless architectures (Next.js, Nuxt, custom), hreflang must be implemented programmatically. The URL-language mapping should be managed centrally (CMS metadata, config file, or database) and injected into page metadata at render time. In Next.js:
// In your <Head> component
const alternates = [
{ hreflang: 'en-US', href: `https://example.com/en-us${path}` },
{ hreflang: 'de', href: `https://example.com/de${path}` },
{ hreflang: 'x-default', href: `https://example.com${path}` },
];
alternates.map(({ hreflang, href }) => (
<link key={hreflang} rel="alternate" hreflang={hreflang} href={href} />
))
Testing and Validating Your Implementation
Implementation without verification is guesswork. These are the tools and methods that confirm your hreflang is actually working.
Google Search Console
Check Settings → International Targeting → Language for detected hreflang usage and errors. GSC reports: missing return tags, invalid language codes, and URLs with errors. These errors directly map to the implementation problems described above. Fix every error GSC reports — they represent real signal loss in international search.
Screaming Frog
Screaming Frog’s hreflang analysis (Configuration → Spider → Extraction → Hreflang) audits your entire site at scale. It identifies: non-canonical hreflang URLs, missing return tags, broken URLs in hreflang clusters, and inconsistent language/country code usage. Run this crawl quarterly and after any significant site changes.
Manual Spot-Testing
For specific pages, use Google’s Rich Results Test to inspect rendered HTML and verify hreflang tags are present in the rendered DOM (not just the static HTML). For JavaScript-rendered sites, rendered DOM inspection is critical — tags present in the HTML template but stripped during rendering are invisible to Google’s crawler. See also our complete technical SEO audit framework for integrating hreflang checks into your full audit process.
Frequently Asked Questions
What is hreflang and why does it matter for SEO?
Hreflang is an HTML attribute that tells search engines which language and/or country a specific page is intended for, and which alternate versions exist for other languages or regions. It prevents international duplicate content issues, eliminates ranking cannibalization between regional variants, and ensures Google shows the correct version of your pages to users in each market. For any site targeting multiple countries or languages, correct hreflang implementation is essential.
What are the most common hreflang mistakes?
The most common mistakes are: missing return tags (every page in the cluster must reference all others, including a self-reference), incorrect language or country code formats, non-canonical pages appearing in hreflang clusters, missing x-default tags, and inconsistent implementation across HTTP/HTTPS or www/non-www URL variants. Any of these errors can cause Google to ignore your hreflang cluster entirely.
Does hreflang improve rankings in international markets?
Hreflang itself doesn’t directly improve rankings. It prevents ranking cannibalization between international versions of the same content, ensures the right page gets served to users in each market, and prevents dilution of ranking signals across duplicate international pages. Correct implementation protects and organizes your existing international rankings rather than creating new ones. Think of it as essential infrastructure, not a ranking booster.
Should I use hreflang in HTML, HTTP headers, or a sitemap?
All three methods are valid and Google accepts all of them. HTML head implementation is the most common and easiest to debug — best for most sites. HTTP header implementation is required for non-HTML files like PDFs. XML sitemap implementation is best for large sites with 1,000+ URLs per language where per-page HTML tags would be complex to maintain. Use only one method — implementing all three creates redundancy without benefit and complicates debugging.
How do I test if my hreflang is implemented correctly?
Use Google Search Console’s International Targeting report to see detected errors. Use Screaming Frog with the hreflang crawler to audit all tags at scale. Use Merkle’s free hreflang testing tool for manual URL checks. Verify that every page in a cluster has a return tag pointing back to it from all other pages. For JavaScript-rendered sites, inspect the rendered DOM (not source HTML) to confirm tags survive client-side rendering.
Can hreflang conflict with canonical tags?
Yes, and this is a significant issue. Only canonical URLs should appear in hreflang clusters. If a URL has a rel="canonical" pointing to a different URL, it shouldn’t be in a hreflang cluster — the canonical should be. Mixing hreflang with non-canonical URLs sends contradictory signals: “this is the authoritative version” (hreflang) vs. “this page’s content is owned by a different URL” (canonical). Google will typically resolve this by ignoring the hreflang tags on non-canonical pages.


