XML sitemap best practices
XML sitemap best practices from Google's documentation: size limits, sitemap index files, which URLs to include, how Google uses lastmod, and how to submit.
An XML sitemap is a list of the URLs you want search engines to know about. It doesn't force anything — Google describes submitting a sitemap as a hint, not a guarantee — but an accurate sitemap helps crawlers find new and updated pages and tells them which URLs you consider canonical. Here's what Google's documentation says matters.
Do you need one?
Google notes that small sites (roughly 500 pages or fewer that you want in search results) whose pages are all well linked internally may not need a sitemap. They tend to help most on large sites, new sites with few external links, and sites with lots of rich media or news content. That said, a correct sitemap rarely hurts and is cheap to maintain when your platform generates it automatically.
Size limits
- One sitemap file: up to 50,000 URLs or 50 MB uncompressed, whichever comes first.
- Larger sites split URLs across multiple sitemaps and list them in a sitemap index file, which can reference up to 50,000 sitemaps.
- You can compress sitemaps with gzip; the 50 MB limit applies to the uncompressed size.
A minimal sitemap index looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-products-1.xml.gz</loc>
<lastmod>2026-09-01</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-articles.xml.gz</loc>
</sitemap>
</sitemapindex>Splitting by section (products, articles, categories) also makes the Search Console Sitemaps report more useful, because you can see indexing problems per section.
Format and location
- UTF-8 encoded, with special characters entity-escaped (for example
&for&). - Use fully qualified, absolute URLs:
https://www.example.com/page, not/page. Google crawls the URLs exactly as listed. - Put sitemaps at the site root where possible. Unless submitted through Search Console, a sitemap only affects URLs in its own directory and below.
- Sitemaps referenced by an index must be on the same site and in the same directory as the index or deeper (unless you've set up cross-site submission).
- URL order inside the file doesn't matter to Google.
Which URLs belong in a sitemap
Include the URLs you want to appear in search results — your canonical URLs. In practice that means every URL in the sitemap should:
- return
200(not a redirect, 404, or soft 404); - be the canonical version (not a parameter or tracking variant, and matching your
rel="canonical"); - be indexable (no
noindex); - not be blocked by robots.txt;
- use the same protocol and hostname as the live site (https, with or without www, consistently).
Listing redirected, blocked or noindexed URLs sends mixed signals and makes the Sitemaps report harder to read. If you have separate mobile URLs, Google recommends listing one version (or annotating both).
lastmod: useful only if honest
Google ignores <priority> and <changefreq>. It does use <lastmod>, but only when it is consistently and verifiably accurate. The date should reflect the last significant change to the page — main content, structured data or links — not a copyright year or a sidebar widget.
Common mistakes:
- Setting every URL's lastmod to the time the sitemap was generated.
- Updating lastmod on every deploy even when content didn't change.
- Using an invalid date format. Use W3C Datetime, such as
2026-09-01or a full timestamp with a timezone.
If Google learns your lastmod values are unreliable, it may stop using them, which removes one of the best signals you have for getting updated pages recrawled. Google's crawl budget guidance specifically recommends keeping sitemaps up to date and using lastmod for updated content.
How to submit
- Search Console Sitemaps report — shows when Google last read the sitemap and any processing errors.
- Search Console API — for programmatic submission.
- robots.txt — add a line such as
Sitemap: https://www.example.com/sitemap.xml. Multiple lines are allowed. See the robots.txt checklist.
Google has retired its old sitemap "ping" endpoint, so rely on the methods above and accurate lastmod values instead.
Sitemaps and crawl diagnostics
Your sitemap is also a statement of intent. Comparing it with what Google actually crawls is one of the fastest ways to find problems:
- Many crawled URLs that aren't in the sitemap can signal crawl traps or duplicate URL variants.
- Sitemap URLs reported as "Discovered – currently not indexed" in the Page Indexing report may point to crawl capacity or quality issues.
- Use the Crawl Stats report to check whether discovery crawling rises after you publish and submit new URLs.
Quick checklist
- Under 50,000 URLs and 50 MB uncompressed per file; index file for more.
- UTF-8, absolute URLs, properly escaped.
- Only canonical, indexable, 200-status URLs that aren't blocked.
- Accurate lastmod; no reliance on priority or changefreq.
- Referenced in robots.txt and submitted in Search Console.
- Generated automatically so it stays in sync with the site.
To see how many URLs your sitemaps expose and how fresh their lastmod dates look, run your domain through the free Crawl Budget Snapshot.
Check your own site
The free Crawl Budget Snapshot fetches a site's public robots.txt and sitemaps and gives a quick crawl-waste score with suggested fixes. It is a starting point, not a replacement for Search Console or log analysis.
References
- Google: What is a sitemap?
- Google: Build and submit a sitemap
- Google: Manage your sitemaps with a sitemap index file
- sitemaps.org: Sitemaps XML format