---
name: xml-sitemap
description: Build or fix an XML sitemap that lists every canonical, indexable URL with accurate lastmod dates, and submit it. Use when pages are not discovered, the sitemap has errors, or the site has no sitemap.
---

# XML sitemap

## Facts to use
- One sitemap file holds at most 50,000 URLs and 50 MB uncompressed. Use a sitemap index for more.
- Use absolute, canonical URLs that return 200. Leave out redirects, noindex pages and error pages.
- Google uses `<lastmod>` only when it is consistently and verifiably accurate. It must show the last significant change to the page. Google ignores `<priority>` and `<changefreq>`.
- Add `Sitemap: https://example.com/sitemap.xml` to robots.txt and submit the sitemap in Search Console and Bing Webmaster Tools.

## Workflow
1. Build the URL list from the router or CMS, not from a crawl only, so new pages are included.
2. Remove URLs that are not canonical, return non-200, or are noindex.
3. Set `lastmod` to the date the main content last changed, in W3C date format.
4. Generate the file at build time or on request, served as `application/xml` with status 200.
5. Add the robots.txt line and submit in both search consoles.
6. Re-check the Sitemaps report for errors and for "Discovered, currently not indexed" pages.

## Template
```xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/pricing</loc>
    <lastmod>2026-02-01</lastmod>
  </url>
</urlset>
```

## Checks
- [ ] Every URL returns 200 and is its own canonical.
- [ ] The sitemap URL is in robots.txt.

## Output
The sitemap or generator code and the list of URLs removed, with the reason.

## Sources
- Google: Build and submit a sitemap. https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap
