How to use the Hreflang Generator
- Put one version per line: a language code, a space, then the full URL — for example
en https://example.com/orfr-ca https://example.com/fr-ca/. - Add an
x-defaultline pointing at your fallback or language-picker page. - Generate the tags. You get a
<link rel="alternate" hreflang="…">block for the page head and thexhtml:linkform for an XML sitemap. - Add the same complete block to every language version, each page included — hreflang only works when it is reciprocal.
- Review the rest of the head with the Meta Tag Checker and validate your sitemap with the Sitemap Checker.
Understanding your results
The head tags. This is the block that goes in the <head> of every version of the page. Each page must list all versions including itself — that self-reference is required.
The sitemap form. If you prefer to declare hreflang in your XML sitemap instead of the head, the tool gives you the xhtml:link version. Your <urlset> needs the xmlns:xhtml namespace, and you repeat a <url> block for each URL.
x-default. This is the version to serve when none of your languages match the visitor. The tool warns when it is missing, because Google strongly recommends it.
Duplicates. Each hreflang code may appear only once per set, pointing to one URL. If the same code is listed twice, the tool flags it — Google ignores conflicting sets.
How this tool works
The generator builds the tags from your list alone — nothing is fetched. It validates each code against the format Google accepts (a language, optionally plus a region, or x-default), upgrades bare URLs to https, and skips any line it cannot parse, telling you which ones.
It cannot verify that the other pages link back, because that lives on your other URLs — but reciprocity is the single most common reason hreflang is ignored, so the tool reminds you. After you publish, confirm the head with the Meta Tag Checker.
Tips
- Be reciprocal. If the English page points to the French one, the French page must point back to the English one. Missing return tags break the whole set.
- Use absolute URLs with
httpsand your real trailing-slash style. hreflang ignores relative URLs. - Language, not region, comes first.
en-gbis valid;gbalone is not —gbis a country, not a language. - Always add x-default for visitors whose language you do not target.
- Pick one method. Declare hreflang in the head or the sitemap, not both, to avoid conflicting signals.
Frequently asked questions
What is hreflang?
hreflang is an attribute that tells search engines which language and region a page is for, and lists the equivalent pages in other languages. It helps Google show the right version to the right user and stops different-language pages from competing with each other.
Where do the tags go?
Either in the <head> of every page version, or in your XML sitemap as xhtml:link entries — this tool gives you both. Use one method consistently; do not mix them for the same pages.
Why does my hreflang get ignored?
Almost always because the tags are not reciprocal (a page is referenced but does not point back), because URLs are relative or wrong, or because x-default is missing. The generator flags these so you can fix them before publishing.
What should x-default point to?
Your main page or a language-selector page — whatever you want shown when none of your targeted languages match the visitor's settings.
Do I need hreflang if my site is one language?
No. hreflang is only for pages that exist in multiple languages or regional variants. A single-language site does not need it.