Hreflang sitemap generator

Describe each locale's URL pattern once, list your page paths, and download a sitemap where every URL carries its full set of xhtml:link alternates.

Describe each locale's URL once with {path}, then list page paths. Best for sitemaps: every page gets its full cluster.

  1. English

  2. French

  3. Spanish in Mexico

  4. Fallback for unmatched languages

4 versions

3 pages × 4 versions (500 pages max)

One <url> entry per version, each listing the whole set, including itself.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
  </url>
  <url>
    <loc>https://example.com/fr/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
  </url>
  <url>
    <loc>https://example.com/mx/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/" />
  </url>
  <url>
    <loc>https://example.com/about</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/about" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/about" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about" />
  </url>
  <url>
    <loc>https://example.com/fr/about</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/about" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/about" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about" />
  </url>
  <url>
    <loc>https://example.com/mx/about</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/about" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/about" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about" />
  </url>
  <url>
    <loc>https://example.com/blog/hreflang-guide</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/blog/hreflang-guide" />
  </url>
  <url>
    <loc>https://example.com/fr/blog/hreflang-guide</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/blog/hreflang-guide" />
  </url>
  <url>
    <loc>https://example.com/mx/blog/hreflang-guide</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/mx/blog/hreflang-guide" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/blog/hreflang-guide" />
  </url>
</urlset>

Checks

Set is valid against Google’s rules.

  • Note · esYou target "es" only with regional codes. Google suggests also providing a catch-all URL for "es" speakers in other countries (hreflang="es").

How hreflang works in a sitemap

Instead of tags in every page head, the sitemap holds the whole map. Google's rules for the sitemap method are:

  • Declare the namespace xmlns:xhtml="http://www.w3.org/1999/xhtml".
  • Create a separate <url> for each version, each with its own <loc>.
  • Inside every <url>, list every version as an <xhtml:link rel="alternate">, including the one in <loc>. Three versions means three entries, each with three identical children.
  • Order inside a <url> doesn't matter, but a consistent order makes review easier. The generator keeps your row order.

That repetition is what makes the return links explicit: the English entry lists French, and the French entry lists English. Paste a finished file into the hreflang validator to confirm every pair is closed.

Using URL patterns

Write each version's address once with a {path} placeholder, e.g. https://example.com/fr/{path}, then paste your page paths. If localized slugs differ (/de/preise vs /pricing), build those clusters in One page mode and combine the output, or export slugs from your CMS into the path list and adjust the rows.

Submitting it

Reference the file from robots.txt with a Sitemap: line or submit it in Search Console. Remember that hreflang in the sitemap and in HTML should not disagree; if you already have head tags, choose one source of truth.

Hreflang sitemap questions

How do I add hreflang to an XML sitemap?

Declare xmlns:xhtml="http://www.w3.org/1999/xhtml" on <urlset>, give every language version its own <url> with a <loc>, and inside each <url> add one <xhtml:link rel="alternate" hreflang="…" href="…"/> for every version, including the page itself.

Do the xhtml:link entries count toward the 50,000 URL limit?

No. Google says child elements do not count towards the sitemap URL limit. Only <url> entries do, although the 50 MB file size limit still applies.

Should I use a sitemap or HTML tags?

Google treats HTML tags, HTTP headers and sitemaps as equivalent. Sitemaps suit large sites because the tags live in one file instead of every page head. Using more than one method brings no benefit in Search.

Can alternates be on different domains?

Yes. Alternate URLs do not need to be on the same domain, so example.de and example.fr can reference each other. Keep in mind that a sitemap may only list URLs under the location it is hosted, unless you verify cross-site submission in Search Console.