Blog
XML sitemap optimization: a checklist, and what an AI agent can check for you
How to optimize an XML sitemap so search engines find your important pages: what to include and leave out, size limits, lastmod, sitemap indexes, how to submit it, and which checks an AI SEO agent can run for you.
Last updated
To optimize an XML sitemap, list only the canonical, indexable pages you want in search, keep each lastmod date accurate, split large sites into several sitemaps under one index, reference the sitemap in robots.txt and submit it in Search Console. A sitemap doesn't make pages rank. It helps search engines find and revisit the right pages, which matters most for new sites, large sites and pages with few internal links.
The sitemap checklist
- It exists and loads. Usually at /sitemap.xml or /sitemap_index.xml, returning status 200 with valid XML.
- It is listed in robots.txt with a full URL:
Sitemap: https://example.com/sitemap.xml. - Every URL returns 200. No redirects, 404s or server errors.
- Every URL is indexable. No noindex, not blocked by robots.txt.
- Every URL is the canonical version. The same address the page's canonical tag points to, with the right protocol, host and trailing slash.
- Important pages are all in it. Compare it with your main pages, products and articles.
- lastmod is real. The date the main content changed, not today's date on every URL.
- It fits the limits. At most 50,000 URLs and 50 MB uncompressed per file.
- It is submitted in Google Search Console, and its status there says Success.
What to leave out
- Pages set to noindex, and pages blocked in robots.txt.
- Redirected URLs, including old http:// or www addresses after a domain move.
- Duplicates: URLs with tracking parameters, sorting and filter options, print versions.
- Thank-you, cart, account and login pages.
- Thin tag or archive pages you don't want ranking.
Each of these sends a mixed signal: you ask search engines to index a page that you also tell them not to index, or that isn't the real address. Too many of them make the sitemap less trusted as a list of what matters.
lastmod, priority and changefreq
Google says it uses lastmod when it is consistently accurate, and ignores priority and changefreq. So the one field worth getting right is lastmod: update it when the page's main content changes, not when a footer or sidebar changes, and never stamp every URL with the same date.
Large sites: sitemap indexes
Split URLs into several sitemaps, for example by type (pages, posts, products) or by date, and list them in a sitemap index file. Submit the index once. Splitting by type also makes Search Console's indexing report easier to read, because you can see which group has the most pages not indexed. If many pages show "Crawled, currently not indexed", read what that status means.
How to generate one
- WordPress: WordPress makes a basic sitemap at /wp-sitemap.xml, and SEO plugins such as Yoast SEO and Rank Math replace it with their own. Use one, not both, and exclude post types you don't want indexed in the plugin settings.
- Shopify: creates /sitemap.xml automatically for products, collections, pages and blog posts.
- Next.js: add a sitemap file to the app folder that returns your URLs with their lastmod dates.
- Other sites: most CMSs and static site generators have a sitemap plugin. Hand-written sitemaps go stale; generate it from your content.
Tell search engines about changes faster
Search engines re-read sitemaps on their own schedule. For faster discovery on Bing and other engines that support it, send changed URLs through IndexNow when you publish. Google doesn't use IndexNow, but a correct sitemap and good internal links cover it.
What an AI SEO agent can check for you
Your CMS should build the sitemap, so "optimizing" it is mostly checking it and fixing settings. That checking is a good job for software:
- Find the sitemap from robots.txt or the usual address, and confirm it loads.
- Crawl the site and flag pages with redirects, broken links, broken canonicals and noindex.
- Send new and changed URLs to IndexNow.
- Re-check every week and alert you when something breaks.
Sonnetpilot's technical SEO audit covers these checks: it reads robots.txt, finds and loads your sitemap, flags a missing or broken one, and crawls your pages for redirects, broken links, canonical problems and noindex pages, with the affected URLs and a fix for each. It never changes indexing directives such as noindex or canonicals without your approval. Add your site and a free 25-page audit starts straight away. Need a robots.txt that points to your sitemap? Use the robots.txt generator.
Frequently asked questions
What should an XML sitemap include?
Only the canonical, indexable pages you want in search: pages that return 200, aren't set to noindex, aren't redirected and aren't blocked by robots.txt. Leave out duplicates, filtered or sorted URLs, thank-you pages and anything behind a login.
How big can an XML sitemap be?
Up to 50,000 URLs and 50 MB uncompressed per file. A larger site splits its URLs into several sitemaps and lists them in a sitemap index file.
Does lastmod matter in a sitemap?
Yes, if it's accurate. Google uses lastmod when it is consistently correct, so set it to the date the page's main content last changed. Google ignores priority and changefreq.
How do I submit a sitemap to Google?
Add a 'Sitemap: https://example.com/sitemap.xml' line to robots.txt, and submit the URL in Google Search Console under Indexing, Sitemaps. For Bing and other engines that support IndexNow, you can also ping changed URLs as you publish them.
Can an AI agent optimize my sitemap?
It can check it: confirm the sitemap is found and loads, compare its URLs with what a crawl finds, and flag pages that are missing, redirected, broken or set to noindex. Your CMS or SEO plugin should generate the sitemap itself, so most fixes are settings there.