Generate a correct hreflang tag template with x-default, ready to fill in with your language and region URLs so Google serves the right version to each visitor.
⚡ Interactive demo — sample data
Generated an hreflang template with x-default plus four example locales. Swap in your real translated URLs before publishing.
x-default tag created, pointing at the reference URL as the fallbackLooks good
Language tags built with valid ISO 639-1 codes (en, es, fr)Looks good
Region example included with ISO 3166-1 code (en-gb)Looks good
All hrefs are absolute, canonical URLs — no relative pathsLooks good
Reminder: add this block to every page in the set, each referencing all alternates including itselfWarning
Generate a correct hreflang tag template with x-default, ready to fill in with your language and region URLs so Google serves the right version to each visitor.
How it works
Enter the page URL
Paste the URL of a page that exists in more than one language or region. We use it as the canonical reference and build an hreflang block around it, including the all-important x-default entry.
Review the generated hreflang tags
You get a complete set of <link rel="alternate" hreflang="…"> tags — one per language/region plus x-default — with example locales filled in so you can see the exact pattern Google expects before you customize it.
Swap in your real URLs and add to your <head>
Replace the example locales and URLs with your actual translated pages, then paste the block into the <head> of every page in the set. Each page must list the whole set, including itself.
What we check
x-default fallback — Generates the x-default tag, which tells Google which version to serve when no language/region match applies — for example a global English or language-picker page. Sets it to your reference URL by default.
Language codes (ISO 639-1) — Uses two-letter ISO 639-1 language codes like en, es and fr. These are the lowercase language part of every hreflang value and must be valid or Google ignores the tag.
Region codes (ISO 3166-1) — Where you target a country, appends an ISO 3166-1 Alpha-2 region code like en-gb or es-mx. The region is optional, but when used it must be a real country code in the language-REGION format.
Correct rel="alternate" syntax — Outputs proper <link rel="alternate" hreflang="…" href="…"> tags with absolute URLs — the only format search engines parse for language/region targeting.
Self-referencing and return tags — Reminds you that every page in the set must reference all alternates including itself. Missing return tags are the single most common reason an otherwise-correct hreflang setup is ignored.
Absolute, canonical URLs — Builds the href values from your page's scheme and host so they're absolute. Relative URLs and inconsistent http/https or www usage are common causes of broken hreflang clusters.
Common issues we catch
Missing return tags — Hreflang annotations must be bidirectional: if page A links to page B as an alternate, B must link back to A. If one page omits the others, Google treats the whole cluster as unreliable and may ignore it entirely.
No x-default — Without x-default, users whose language or region doesn't match any of your listed versions get whatever Google guesses. x-default lets you control the fallback — typically a global or language-selector page.
Invalid language or region codes — Using en-uk instead of en-gb, or making up codes like en-eu, silently breaks the tag. Language must be ISO 639-1 and the optional region must be ISO 3166-1 Alpha-2 — and they're combined as language-REGION.
Relative URLs in href — Hreflang requires absolute URLs (https://example.com/es/page), not /es/page. Relative hrefs are ignored, so the alternate is invisible to search engines even though the tag looks present.
Mismatched canonical and hreflang — A page's canonical tag should point to itself, not to a different language version. A canonical that points elsewhere while hreflang points back creates conflicting signals that cancel each other out.
Tags on the wrong pages — Hreflang goes in the <head> of every page in the set (or in the sitemap or HTTP headers), but a frequent mistake is adding it only to the homepage. Every translated URL needs its own complete block.
Region used when you mean language — es-mx targets Spanish speakers in Mexico specifically, not all Spanish speakers. If you have one Spanish page for everyone, use es alone — adding a region needlessly narrows who sees it.
Where this matters
Google Search — Google uses hreflang to serve the right language/region version in results and to avoid treating translations as duplicate content. It's the primary engine that acts on these tags.
Yandex — Yandex supports hreflang annotations as well, so the same markup helps international sites that target Russian-speaking and CIS audiences.
HTML <head>, sitemaps & HTTP headers — Hreflang can live in any of three places. This generator outputs the <head> link-tag form, the most common; for very large sites the XML sitemap form is often easier to maintain.
WordPress (WPML, Polylang) & multilingual plugins — Multilingual plugins usually emit hreflang automatically, but they sometimes miss x-default or get return tags wrong. Use this to understand the correct pattern and audit what your plugin produces.
International & multi-region sites — Any site with language or country variants — translated content, regional pricing, country-specific stores — needs hreflang so the correct version ranks and shows for each audience.
Frequently asked questions
What is hreflang?
Hreflang is an HTML annotation that tells search engines which language and region a page is for, and links it to its equivalents in other languages. It ensures a French user sees your French page and a UK user sees your UK page, and stops engines from treating translations as duplicate content.
What is the x-default tag for?
x-default specifies the fallback version to serve when none of your language/region tags match the user — for example a visitor whose language you don't publish. It's commonly set to a global English page or a language-selector landing page so you control that fallback rather than leaving it to chance.
Do I really need to list every page in the set on every page?
Yes. Hreflang must be bidirectional and complete: each page in a cluster references all the alternates, including itself. If even one page omits a return tag, search engines may distrust and ignore the whole cluster, so completeness matters more than anything else.
What's the difference between a language code and a region code?
The language code (ISO 639-1, like en or es) is required and identifies the language. The region code (ISO 3166-1 Alpha-2, like gb or mx) is optional and narrows it to a country, written as language-REGION such as en-gb. Use language alone unless you genuinely have country-specific content.
Where do I put the hreflang tags?
The simplest place is the <head> of each page, which is what this tool generates. You can alternatively put them in your XML sitemap or in HTTP headers — useful for non-HTML files or very large sites. Pick one method and apply it consistently across the whole set.
Why is my hreflang being ignored?
The usual culprits are missing return tags, invalid codes (like en-uk instead of en-gb), relative instead of absolute URLs, or a canonical tag pointing to a different language. Fix those, confirm every page references the full set, and re-test in Search Console's international targeting reports.
Does hreflang help my rankings?
It doesn't boost rankings on its own, but it ensures the right version ranks for the right audience and prevents your translations from competing with each other as duplicates. For international sites that's the difference between showing the correct page and showing the wrong one or none at all.
Can I generate hreflang for more than the example languages?
Yes. The output is a template with a few example locales — add as many <link rel="alternate"> lines as you have versions, each with the correct language (and optional region) code and that version's absolute URL. Just make sure every page in the set lists all of them.
This is one of several free SEO tools from Custom Web Audits.
For a complete, prioritized analysis of your whole website,
run a full audit.