If your website serves visitors in more than one language or country, you have probably seen this frustrating problem firsthand: a user in London searches for your brand on Google, but your US pricing page in dollars ranks above your UK page in pounds. Or worse, your Spanish and English pages compete against each other because they share similar product names.
That is the exact problem hreflang tags are built to solve. Yet in practice, broken hreflang setups are everywhere—usually because of a single mismatched country code, a missing return link, or a conflicting canonical tag that tells Google to ignore the entire setup.
Here is how hreflang actually works under the hood, how to write a clean set of tags that search engines respect, and how to avoid the traps that silently break international SEO.
What Hreflang Actually Does (And a Common Myth)
Many developers assume Google reads the hreflang attribute to figure out what language a page is written in. According to Google's official documentation on localized versions, it does not—Google uses its own text algorithms to detect the language of a page.
Instead, hreflang works like a routing table for search results. Once Google knows that three URLs are localized versions of the exact same page (for example, US English, British English, and French), it uses your hreflang tags to swap the right URL into the search results based on the searcher's language and location.
The 3 Golden Rules Every Hreflang Cluster Must Follow
Suppose you have a pricing page available in English (https://example.com/en/pricing), French (https://example.com/fr/pricing), and German (https://example.com/de/pricing), plus a global selector homepage for everyone else.
For Google to trust your tags, every page in that group has to follow three strict rules:
- Every page must link to itself (Self-Referencing): The English page cannot just list the French and German URLs—it must also include an
hreflang="en"tag pointing to its own English URL. - Every link must be reciprocal (Return Tags): If your English page links to your French page, your French page must link back to your English page. If that return tag is missing, Google ignores the relationship so third-party sites cannot arbitrarily claim to be the French version of your site.
- Every URL must be fully qualified (Absolute URLs): Always include the full
https://protocol and domain. Relative paths likehref="/fr/pricing"will fail.
When those three rules are applied, the HTML <head> block on all three pages looks identical:
<!-- Paste this exact block inside the <head> of the /en/, /fr/, and /de/ pricing pages -->
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/pricing" />
<link rel="alternate" hreflang="de" href="https://example.com/de/pricing" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
Language and Region Codes That Trip Developers Up
The value inside hreflang="language-REGION" is not free-form text. The first part must be a two-letter ISO 639-1 language code, and the optional second part must be a two-letter ISO 3166-1 alpha-2 country code separated by a hyphen.
You can specify a language on its own (hreflang="es" for Spanish speakers anywhere), but you can never specify a country code on its own. If you guess a code instead of checking the ISO table, your tag either gets ignored or targets the wrong language entirely:
| Target Audience | Common Mistake | Why It Fails | Correct Code |
|---|---|---|---|
| English speakers in the United Kingdom | hreflang="en-UK" |
UK is not the official ISO 3166-1 country code for Great Britain, and uk as a language code means Ukrainian. |
hreflang="en-GB" |
| Users in Belgium (Dutch & French) | hreflang="be" |
A bare two-letter code is always read as a language. be is the language code for Belarusian, not Belgium. |
hreflang="nl-BE" and hreflang="fr-BE" |
| Czech speakers | hreflang="cz" |
CZ is the country code for Czechia, not the language code. |
hreflang="cs" (or cs-CZ) |
| Japanese speakers in Japan | hreflang="jp" |
JP is the country code; the ISO 639-1 language code for Japanese is ja. |
hreflang="ja" (or ja-JP) |
| Users across the European Union | hreflang="en-EU" |
EU is not a valid country code in the ISO 3166-1 standard supported by search engines. |
hreflang="en" (general fallback) |
| Underscore separator | hreflang="en_US" |
Locale strings in code often use underscores, but hreflang requires a hyphen. |
hreflang="en-US" |
4 Mistakes That Cause Google to Silently Ignore Your Hreflang Tags
Even if your ISO codes are spotless, four architectural mistakes can wipe out your international setup—a problem highlighted across recent technical audits like TechSEO Vitals' breakdown of ignored hreflang tags.
1. Pointing Every Regional Page's Canonical Tag to the Default URL
This is the single most destructive mistake on multi-regional websites. Suppose you have a US page (/en-us/shoes) and a UK page (/en-gb/shoes). Because the text on both pages is 95% identical English, a developer adds a canonical tag on the UK page pointing to the US page to "prevent duplicate content."
Never do that. A canonical tag tells Google: "Do not index this UK URL; fold it into the US URL." Meanwhile, your hreflang tag tells Google: "Show this UK URL to searchers in the UK." Those two instructions contradict each other. Instead, every localized page must have a self-referencing canonical tag:
<!-- On https://example.com/en-gb/shoes -->
<link rel="canonical" href="https://example.com/en-gb/shoes" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/shoes" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/shoes" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en-us/shoes" />
If you need to generate clean self-referencing canonical tags alongside your language tags, you can build them with the Varkido Canonical URL Generator.
2. Auto-Redirecting Visitors (and Googlebot) by IP Address
It is tempting to detect a visitor's country from their IP address and automatically redirect anyone from the United States to /en-us/. Here is the problem: as explained in Google's guide to locale-adaptive pages, Googlebot crawls primarily from US IP addresses.
If your server forces every US IP address to redirect away from /fr/ or /en-gb/ to /en-us/, Googlebot can never reach your French or UK pages to verify their reciprocal return tags. Instead of forcing IP redirects, display a non-intrusive banner suggesting the visitor's local store or language.
3. Forgetting the x-default Fallback
What should Google show a searcher in Brazil (pt-BR) if your website only supports English (en-US, en-GB) and French (fr-FR)? That is what hreflang="x-default" defines. Point x-default either to your global country-selector page or to your primary international version (usually your main English URL).
4. Linking to Redirected, Broken, or Blocked URLs
Every URL inside an hreflang cluster must return an HTTP 200 OK status code and be open for crawling and indexing. If one of your alternate URLs triggers a 301 redirect, returns a 404, carries a noindex tag, or is blocked in your robots.txt file, Google drops that link from the cluster.
HTML Head vs. XML Sitemap vs. HTTP Headers: Which Should You Use?
Google supports three ways to declare hreflang relationships. You only need to use one method per page—duplicating them across both HTML and sitemaps only increases the chance of a mismatch:
- HTML
<link>tags in the<head>: Best for small-to-medium websites holding 2 to 10 language or regional versions. Easy to inspect in the browser source and simple to manage in CMS templates. - XML Sitemap (
xhtml:linkannotations): Best for enterprise sites with 20+ locales where adding dozens of<link>lines to every HTML page would bloat the DOM size. (For standard sitemap creation, see the Varkido XML Sitemap Generator.) - HTTP Response Headers: Only needed for non-HTML files such as translated PDF manuals or downloadable guides that do not have an HTML
<head>section.
How to Generate Clean Hreflang Tags
Writing <link rel="alternate"> blocks by hand is slow, and a single typo in a quotation mark or language code invalidates the line. You can build a complete, error-free block directly in your browser using the Varkido Hreflang Generator:
- Enter each language or region code: Type the valid ISO code (for example,
en,en-GB,fr, orx-default) into the language field. - Add the matching target URL: Paste the full
https://URL for that specific language version, and click + Add row for each additional translation—remembering to include the current page's own URL in the list. - Generate and copy: Click Generate to create the formatted HTML
<link>tags instantly on your device, then click Copy and paste the block into the<head>section of every page in that translation group.
Frequently Asked Questions (FAQ)
Do I still need the HTML lang attribute if I use hreflang tags?
Yes. Keep <html lang="en-GB"> on your opening HTML tag even when you use hreflang. While Google relies on hreflang for search indexing, screen readers, browser translation prompts, and spellcheckers rely on the lang attribute for accessibility.
Can I link a general language tag (`en`) and a regional tag (`en-GB`) together?
Yes, and it is a smart setup if you have one dedicated store for the UK (en-GB) and want your other English store to serve all remaining English speakers worldwide (en). Searchers in the UK will see the en-GB page, while English speakers in the US, Canada, and Australia will see the general en page.
What happens if only half of my website is translated into French?
Only add hreflang="fr" tags to the specific pages that actually have a live French equivalent. Never point page-level hreflang tags from 50 different English articles to your French homepage just to have a tag present—Google treats that as a soft 404 or mismatched target and ignores the annotation.
Are hreflang codes case-sensitive?
By convention, language codes are written in lowercase and region codes in uppercase (en-GB, pt-BR). However, Google's parser accepts both en-GB and en-gb as long as the ISO letters themselves are valid and separated by a hyphen.