All guides
XML sitemap guide

XML Sitemaps: The Complete Technical Guide

A practical reference for building, validating, submitting, and maintaining XML sitemaps without sending search engines misleading signals.

By SitemapKit Engineering9 min readUpdated

Key takeaways

  • A sitemap is a discovery signal, not a guarantee that a URL will be indexed.
  • Only include canonical, indexable URLs that return a successful response.
  • Split large URL sets into focused sitemap files and connect them with a sitemap index.
  • Use lastmod only when it reflects a meaningful change to the page.

What an XML sitemap actually does

An XML sitemap is a machine-readable inventory of URLs you want search engines to discover. It is especially useful when a site is new, large, frequently updated, rich in media, or not perfectly connected through internal links.

A sitemap does not replace crawlable navigation. Search engines still evaluate canonical tags, robots directives, response codes, content quality, and internal links before deciding whether to index a URL. Treat the file as a clean feed of eligible pages rather than a complete export of your database.

The minimum valid structure

Each URL belongs in a url element inside a urlset. The loc value must be an absolute URL using the canonical protocol and hostname. Optional lastmod values should use an ISO 8601 date or timestamp.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/guides/xml-sitemaps</loc>
    <lastmod>2026-07-18</lastmod>
  </url>
</urlset>

Escape XML-sensitive characters in URLs. For example, an ampersand in a query string must be written as &amp;.

Which URLs belong in the file

Include the preferred version of every useful public page. Exclude redirects, errors, duplicate parameter URLs, login areas, noindex pages, and URLs canonicalized somewhere else. Every sitemap URL should agree with the signals on the page itself.

  • Returns HTTP 200 without requiring a session
  • Uses the preferred HTTPS hostname
  • Has a self-referencing canonical when it is a unique page
  • Is allowed to be crawled and does not contain a noindex directive
  • Contains content useful enough to stand on its own

Sitemap files and sitemap indexes

A single sitemap is limited to 50,000 URLs and 50 MB when uncompressed. Sites that exceed either limit should create several sitemap files and list them in a sitemap index. Splitting by content type—products, articles, categories, videos, or locales—also makes coverage problems easier to diagnose.

Keep every referenced sitemap on a host and path it is allowed to cover. Submit the index in Search Console and declare it in robots.txt so crawlers can find the inventory through more than one route.

A maintenance workflow that stays trustworthy

Generate sitemaps from the same canonical URL source used by your application. Validate response codes before publishing, remove deleted URLs promptly, and update lastmod only after meaningful content changes. Monitor submitted-versus-indexed counts by sitemap type instead of treating one global number as a health score.

For SitemapKit, the practical pattern is to discover sitemap files first, extract their URLs, normalize duplicates, and then validate the resulting inventory against the pages you actually want indexed.

Check an XML sitemap

Validate a public sitemap before submitting or auditing it.

Open the free tool

Frequently asked questions

Does an XML sitemap improve rankings directly?

No. It helps discovery and diagnostics, but ranking still depends on relevance, quality, usability, internal links, and authority.

Should every page be included?

Only include canonical, indexable pages you would be comfortable seeing in search results. Utility, account, duplicate, redirected, and error URLs should stay out.

How often should a sitemap be regenerated?

Regenerate it when the eligible URL inventory changes. High-frequency sites may update continuously; stable sites can update only after publishing, deleting, or canonicalizing pages.

Primary references

See our technical methodology and editorial policy.

How to organize millions of URLs into stable child sitemaps that are easier to generate, crawl, and diagnose.

A precise lastmod implementation guide for content, ecommerce, and programmatic pages—without fake freshness signals.

A symptom-first troubleshooting guide for the XML, HTTP, URL, and indexability errors that make sitemap reports unreliable.