What Is Hreflang?
Hreflang (short for "HTML language reference") is a set of HTML annotations that tell search engines which language and, optionally, which region each version of a page is intended for. It solves a very specific problem: when you publish the same content in multiple languages or target different regions with the same language, Google needs to know which version to show to which user.
The tag itself looks like this:
<link rel="alternate" hreflang="en-US" href="https://example.com/">
Anatomy of a Hreflang Value
- Language (required): ISO 639-1 two-letter code, e.g.
en,fr,de. Three-letter ISO 639-2 codes are also accepted by Google. - Region (optional): ISO 3166-1 alpha-2 two-letter country code, e.g.
US,GB,CA. Separated by a hyphen. - x-default (special): the fallback version for users whose language/region isn't matched by any other annotation.
The Rules You Must Follow
- Every version must link to every other version — including itself. If you have 5 languages, each page carries 5 hreflang tags.
- Use absolute URLs — always start with
https://and the full domain. - Language first, region second:
en-US, notUS-en. - Hyphens, not underscores:
en-GB, noten_GB. - Region must be uppercase:
en-GB, noten-gb. - One x-default per cluster — usually the global or language-selector page.
- Never use hreflang as a canonical substitute — the two tags do different jobs.
Common Hreflang Mistakes
| Mistake | Example | Fix |
|---|---|---|
| Underscore separator | en_US | Use hyphen: en-US |
| Lowercase region | en-us | Uppercase: en-US |
| Invalid language code | eng-US for English in the US | Use ISO 639-1: en-US |
| Missing return tag | Page A links to B, but B doesn't link back to A | Add reciprocal tags on both pages |
| No self-reference | Only other languages are listed | Add a tag with your own hreflang |
| Relative URL | /fr/ | Use full URL: https://example.com/fr/ |
| Duplicate hreflang | Two en-US entries | Keep one; disambiguate by URL path |
| Missing x-default | Only language variants present | Add an x-default fallback |
How to Use This Tester
- Validate HTML: paste a full HTML document (or just the hreflang tags) and click Validate. You'll get a full annotation table plus a prioritised list of issues.
- Validate by URL: paste a live page URL. The tool fetches the HTML via CORS proxies and runs the same validation.
- Generate Tags: paste your hreflang code / URL pairs and produce a ready-to-paste block with a self-referencing tag and optional x-default.
Pro Tip: Hreflang is a signal, not a directive. Google uses it together with content language, canonical tags and user settings. That means hreflang mistakes won't always cause a visible problem in the short term — but they'll reduce how reliably your regional and language pages rank in the right places.
⚠️ AI-Generated Tool Notice: This tester was built with AI assistance. The language and country code lists are embedded static references and may not include every ISO 639-3 or ISO 3166-1 code. Always cross-check against the official IANA Language Subtag Registry and Google's Search Console International Targeting report before finalising changes.