hreflang sitemap generator
Tell Google which URL to show in which language or country, without editing the <head> of every page.
Loading…
How it works
hreflang can be declared in HTML <link> tags, HTTP headers, or the sitemap. The sitemap method is easiest to maintain for big sites: every language version gets its own <url> entry, and each entry lists all versions, itself included, as <xhtml:link rel="alternate"> elements.
That "every version lists every version" rule is where hand-written hreflang breaks. Missing return links make Google ignore the annotation. The generator writes the full set for every URL from a single line of input.
The rules
- Declare xmlns:xhtml="http://www.w3.org/1999/xhtml" on <urlset>.
- Each language version needs its own <url> listing all alternates, including a link to itself.
- Codes: ISO 639-1 language, optionally with ISO 3166-1 alpha-2 region (en-GB, not en-UK). Use x-default for the fallback.
- All URLs must be absolute and canonical.
Source: Google: Localized versions of your pages. Check the finished file with the sitemap validator; it recognises all four extensions.
Questions people ask
Is sitemap hreflang as good as hreflang in HTML?
Google treats all three methods (HTML, HTTP header, sitemap) as equivalent. Use one method consistently rather than mixing them.
Do I need x-default?
It is optional but recommended. It names the page for visitors whose language or region matches none of your versions, often a language picker or your main English page.
Why is my hreflang ignored?
The usual causes: missing return links, invalid codes such as en-UK, URLs that redirect or are not canonical, and pages blocked from crawling.