Technical SEO
Multilingual XML Sitemaps with Hreflang: A Field Guide
In a sitemap, every version of a page gets its own url entry, and each entry lists every alternate, itself included, with xhtml:link elements. Get that pattern right and sitemaps are the easiest hreflang method to keep in sync.
In brief
- Declare the namespace
xmlns:xhtml="http://www.w3.org/1999/xhtml"on the urlset. - Each version gets its own
<url>entry, and each entry lists every alternate, itself included. Order does not matter. - One sitemap holds at most 50,000 URLs or 50MB uncompressed. An index file holds up to 50,000 sitemaps.
- Google ignores priority and changefreq, and uses lastmod only when it is consistently accurate.
Google treats sitemap annotations as equivalent to link tags in the HTML head and to HTTP headers. Sitemaps have one practical advantage for large gambling sites: the whole set for every page sits in files your build can generate from one table of URLs, instead of in templates owned by different market teams.
The pattern
Here is one page in four versions plus an x-default, on example domains. Note that there are five <url> entries, one per URL, and each carries the same five xhtml:link lines.
<?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/en-gb/responsible-gambling/</loc>
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/responsible-gambling/"/>
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/verantwortungsvolles-spielen/"/>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://example.es/juego-responsable/"/>
<xhtml:link rel="alternate" hreflang="en-CA" href="https://example.com/en-ca/responsible-gambling/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/responsible-gambling/"/>
</url>
<!-- four more url entries: one for each other loc, each with the same five xhtml:link lines -->
</urlset>
The workbench writes this block for you from a list of locale and URL pairs, with every entry filled in.
Rules from Google's documentation
- Namespace. Specify the xhtml namespace on the urlset element.
- One entry per version. With three versions of a page, the sitemap has entries for the URL of each version.
- Full set per entry, self included. Each
<url>lists every alternate version, including itself. - Order is free. The order of the
xhtml:linkchildren does not matter. - Absolute URLs, UTF-8. Use fully qualified URLs, and encode the file as UTF-8.
- Limits. 50MB uncompressed or 50,000 URLs per sitemap; split larger sets into several sitemaps and list them in a sitemap index (up to 50,000 sitemaps per index, and up to 500 index files per site in Search Console).
- Ignored fields. Google ignores
<priority>and<changefreq>. It uses<lastmod>when the value is consistently and verifiably accurate.
Cross-domain sets
A brand licensed in Spain normally publishes its Spanish site on a .es domain, because Ley 13/2011 requires a dedicated .es website. Its hreflang sets then span two or more hosts. Google says the sitemaps referenced from an index must be hosted on the same site as the index file unless cross-site submission is set up, so the simplest arrangement is one sitemap set per host, each listing its own URLs as <loc> entries with the full cross-domain set of alternates. Verify every host in Search Console so you can submit and monitor each one.
Sizing the files
Each entry carries every alternate, so the file grows with the square of the number of versions. Five versions of 10,000 pages means 50,000 <url> entries, which already reaches the URL limit for one file, and each entry holds five links. Split by template or by section (for example, sportsbook, casino games, help pages), and keep each file well under both limits so a growing catalog does not push a file over without anyone noticing.
Common errors
| Error | Effect | Fix |
|---|---|---|
| Namespace missing or misspelled | The xhtml:link elements are not read as hreflang | Declare xmlns:xhtml="http://www.w3.org/1999/xhtml" |
| Only the "main" version has an entry | Other versions lack their own set, so return links fail | One <url> per version |
| Entry omits itself | Breaks the self-reference rule | Include the entry's own URL in its links |
Unescaped & in a URL | The file is not valid XML | Write & inside XML |
| lastmod set to the build time on every URL | Google may stop trusting the field | Change lastmod only when the page changes |
| Sitemap and HTML tags disagree | Conflicting sets for the same page | Generate both from one table, or use one method |
Testing a sitemap
- Validate the XML. A single unescaped ampersand makes the whole file unreadable.
- Count entries per URL group: every group should have as many
<url>entries as versions. - Check that every
<loc>returns status 200, is indexable and is its own canonical. - Submit the sitemap or index in Search Console for each host, and read the processing report for errors.
Questions
Can I put hreflang in the sitemap and in the HTML?
Google treats the methods as equivalent and does not forbid using more than one, but every mismatch between them is a bug. If you use both, generate them from the same source.
Do I need a separate sitemap per language?
No. Google's format puts every version's entry, with its full set of alternates, in the sitemap. Splitting by language or by section is a choice for size and monitoring, not a requirement.
Does lastmod help hreflang?
lastmod tells Google when a page changed, which can help recrawling after you fix a set. Google uses it only when it is consistently accurate, so never set it to the build time for unchanged pages.
Sources
- Google Search Central, Tell Google about localized versions of your page, last updated September 21, 2026.
- Google Search Central, Build and submit a sitemap, last updated July 8, 2026.
- Google Search Central, Manage your sitemaps with sitemap index files, last updated December 10, 2025.
- BOE, Ley 13/2011, de regulación del juego (consolidated text), art. 10.4.
Spotted an error? Tell the editors and include a link to the source. Corrections are noted on the page they change (corrections policy).