Skip to content
SEO Madmanby Adam Hafez
Free tool

Hreflang XML sitemap generator

Build a sitemap with xhtml:link hreflang annotations for localized pages, with every alternate listed on every URL as Google's documentation requires.

Runs entirely in your browser. Nothing you enter is uploaded, logged or stored.

Nothing you enter here is sent anywhere; the XML is built in your browser only.

    sitemap.xml

    Key takeaways

    • Google supports hreflang annotations in an XML sitemap as an alternative to link tags in the page head or HTTP headers.
    • Each url element must list every alternate version of the page as an xhtml:link, including the page itself.
    • The sitemap needs the xhtml namespace declared on its urlset element for the xhtml:link elements to be valid.
    • The x-default value is optional and points at a fallback page for visitors whose language matches none of the listed versions.
    • Language codes use ISO 639-1 and an optional ISO 3166-1 Alpha-2 region, so en and en-GB are valid but eng is not.

    What it takes

    • A language code and full URL for each localized version
    • A blank line between each group of alternate pages
    • An optional x-default row for each group

    More tools

    All of them free, all of them browser-only.

    Browse the tools

    How to use it

    1. 1List one version per lineWrite the code, a space, then the full https URL, for example en followed by the English page. Codes like en-gb are normalized to en-GB.
    2. 2Separate pages with a blank lineEvery page that has translations is its own group. The tool builds one set of annotations per group, so groups never cross-reference each other.
    3. 3Add x-default where you have a fallbackUse it for a language selector or a catch-all page. It is optional, and the tool notes when a group has none.
    4. 4Resolve the errorsThe tool reports a code pointing at two URLs, a code that is not language or language-region, and any URL that is not fully qualified https.
    5. 5Copy the XML into your sitemapSave it as a sitemap file, or merge the url blocks into an existing sitemap that already declares the xhtml namespace, then submit it in Search Console.

    Hreflang can live in three places: link tags in the page head, HTTP headers, or a sitemap. For a site with many localized pages the sitemap is often the easiest to maintain, because the annotations sit in one file instead of every template. This tool writes that file from a plain list, in your browser, without sending your URLs anywhere.

    How the sitemap form differs from head tags

    The rule that trips people up is that every url element lists all the alternates, itself included. With three language versions, each of the three url entries carries three xhtml:link lines. The generator does that expansion for you, so a set of three rows becomes three url blocks of three links each. That repetition is expected and is not a duplication error.

    What is checked and what is not

    The tool checks what it can check from the text you give it: code format, absolute https URLs, one URL per code within a group, and that a group has at least two versions. It cannot tell whether a URL really returns a page, or whether the translated page points back to the others, because it never fetches anything. Google’s documentation also says a language code can be written with or without a region, and that x-default is optional, which is why a missing one is reported as information rather than as a problem.

    Sources

    1. 1.Tell Google about localized versions of your page - Google Search CentralPrimary
    2. 2.Sitemaps XML format - sitemaps.org