
Key points
- List only canonical, indexable pages that return 200: no redirects, errors or noindex pages.
- One file holds up to 50,000 URLs and 50 MB uncompressed. Bigger sites use a sitemap index.
- Google ignores
priorityandchangefreq. A truthfullastmodis the one optional field worth keeping.
What a sitemap does
Search engines mostly find pages by following links. A sitemap gives them a second route, which matters for new sites, large sites, pages with few internal links and content that changes often. It is a hint: search engines decide what to crawl and index.
The format
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/guides/robots-txt/</loc>
<lastmod>2026-03-27</lastmod>
</url>
</urlset>
Each <loc> is a full address. The namespace on the root element must match exactly: http://www.sitemaps.org/schemas/sitemap/0.9, with http, not https. Special characters such as & must be escaped in the XML.
Limits and sitemap indexes
A single sitemap may list at most 50,000 URLs and be at most 50 MB uncompressed. It can be gzip compressed (sitemap.xml.gz). Above those limits, split the list and publish a sitemap index that names each file:
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>https://example.com/sitemap-posts.xml</loc></sitemap>
<sitemap><loc>https://example.com/sitemap-pages.xml</loc></sitemap>
</sitemapindex>
Splitting by section (posts, products, pages) also makes it easier to see which part of the site has indexing problems.
Which URLs belong in it
- The canonical version of each page, using your preferred protocol and host.
- Pages that return HTTP 200 and are meant to be indexed.
- Not: redirecting URLs, 404s, noindex pages, parameter variations, internal search results or login pages.
A sitemap that mixes in redirects and errors teaches crawlers to distrust it. Keep it clean and generate it automatically so it never drifts.
Optional fields
- lastmod: the date the page last changed in a meaningful way, in W3C format (
2026-03-27). Google uses it when it proves reliable. A build date on every URL teaches Google to ignore it. - priority and changefreq: ignored by Google. You can leave them out.
Publishing it
- Put the file at a stable address, usually
/sitemap.xml. - Add a line to robots.txt:
Sitemap: https://example.com/sitemap.xml. Every crawler then finds it. - Optionally submit it in Google Search Console and Bing Webmaster Tools to see processing errors and index coverage.
Common mistakes
- Wrong namespace (https instead of http) or a root element that is not
urlsetorsitemapindex. - URLs on another host or the http version of an HTTPS site.
- Duplicates and redirecting URLs.
- Sitemap blocked by robots.txt or served with an error status.
- Stale files that still list pages deleted months ago.
A sitemap is not a way to remove pages. To drop a page from search, return 404 or 410, or use noindex, and take it out of the sitemap.
See also: hreflang explained, Redirects: 301 vs 302, Find and fix broken links.
FAQ
Does a sitemap improve rankings?
Not directly. It helps pages get discovered and crawled. Ranking depends on content quality, links and many other signals.
How often should I update the sitemap?
Automatically, whenever content changes. Most CMS platforms and SEO plugins regenerate it for you.
Do small sites need one?
A small site with good internal links is usually found without one, but a sitemap is cheap and useful for monitoring.
Can I have several sitemaps?
Yes. List them all in a sitemap index, or add several Sitemap lines to robots.txt.