An XML sitemap is one of the simplest technical SEO files you will ever create, yet it is also one of the most frequently broken. We regularly audit sites whose sitemaps list redirected URLs, pages blocked by robots.txt, or thousands of filtered product URLs nobody wants in search results. A sitemap like that does not help Google; it sends mixed signals.
This guide explains what an XML sitemap actually does in 2026, when you genuinely need one, how to build a clean file (by hand or with your CMS), and how to submit and monitor it in Google Search Console. You will also find code samples, a quality checklist and the mistakes we see most often.
If you are new to the wider topic, our beginner's guide to technical SEO gives the bigger picture. Here we focus on doing sitemaps properly.
Key Takeaways
- An XML sitemap lists the URLs you want search engines to discover and crawl; it is a hint, not a command.
- Only include canonical, indexable URLs that return a 200 status code.
- One file can hold up to 50,000 URLs or 50MB uncompressed; use a sitemap index for more.
- Google ignores
<priority>and<changefreq>but uses accurate<lastmod>dates. - Submit via Search Console and reference the file in robots.txt, then monitor the Sitemaps and Page indexing reports.
What Is an XML Sitemap?
An XML sitemap is a machine-readable file that lists the pages, and optionally images, videos or news articles, that you want search engines to know about. It follows the open sitemaps.org protocol, which Google, Bing and other engines support.
Think of it as a delivery manifest. Crawlers still find most pages through links, but the sitemap tells them, “Here is the full list of URLs I care about, and here is when each one last changed.” That is especially useful for pages that are deep in the architecture or have few internal links pointing to them.
“helps search engines discover URLs on your site, but it doesn't guarantee that all the items in your sitemap will be crawled and indexed”
— Google Search Central, What is a sitemap
In other words, a sitemap helps discovery. It does not override quality judgements, duplicate detection or a noindex tag.
Do You Need an XML Sitemap?
Google's documentation says you might need a sitemap if your site is large, if it is new with few external links, or if it has lots of rich media or news content. It also notes that small sites of about 500 pages or fewer, with good internal linking, may not need one at all.
In practice, we recommend a sitemap for almost every business site because modern CMSs generate one automatically. The table below shows where it matters most.
| Site type | How much a sitemap helps | Why |
|---|---|---|
| Small brochure site (under ~500 pages), well linked | Low | Google can usually discover every page by following links. |
| New site with few backlinks | High | Few external links point in, so discovery relies more on your own signals. |
| Ecommerce store with thousands of products | High | Products deep in categories and pagination can be slow to discover. |
| News or publishing site | High | Fresh URLs and accurate lastmod dates speed up recrawling. |
| Site with lots of video or images | Medium–High | Media extensions give Google extra details it may not find otherwise. |
XML Sitemap Format: The Essentials
A basic sitemap is short. Here is a valid example with two URLs:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2026-09-30</lastmod>
</url>
<url>
<loc>https://www.example.com/services/technical-seo/</loc>
<lastmod>2026-08-14</lastmod>
</url>
</urlset>
The rules that matter, all taken from Google's build-a-sitemap documentation:
- Encoding: the file must be UTF-8 encoded.
- Absolute URLs: use fully qualified URLs such as
https://www.example.com/page/, never relative paths like/page/. - Size limits: one sitemap can contain up to 50,000 URLs or 50MB uncompressed.
- Tags Google uses:
<loc>is required;<lastmod>is used when it is consistently accurate. - Tags Google ignores:
<priority>and<changefreq>.
Sitemap index files for large sites
If you exceed the limits, split URLs into multiple sitemaps (for example by content type) and list them in a sitemap index. Google's documentation says an index file may contain up to 50,000 loc entries, and you can submit up to 500 index files per site in Search Console.
<?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.xml</loc>
<lastmod>2026-10-01</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-blog.xml</loc>
<lastmod>2026-09-28</lastmod>
</sitemap>
</sitemapindex>
Splitting by type has a hidden benefit: when you look at indexing data per sitemap in Search Console, you can see at a glance whether products, categories or blog posts have a coverage problem.
What to Include (and Exclude)
The best sitemaps are curated. Every URL in the file is effectively a statement: “This is a canonical page I want indexed.” Google treats sitemap inclusion as a weak canonicalisation signal, so listing the wrong version of a URL works against you. For more on choosing the preferred version, see our explainer on the canonical tag and our guide to duplicate content.
| Include | Exclude |
|---|---|
| Canonical URLs returning 200 OK | URLs that redirect (301/302) |
| Important pages: services, products, categories, articles | 404 and 410 pages |
| The exact protocol and host you use (e.g. https + www) | Pages with a noindex tag |
| Recently updated content with accurate lastmod | URLs blocked in robots.txt |
| Language versions (optionally with hreflang annotations) | Parameter, session-ID, sort and filter URLs |
| Key landing pages with few internal links | Internal search results, cart, login and thank-you pages |
How to Create an XML Sitemap: Step by Step
- Check whether one already exists. Try
/sitemap.xml,/sitemap_index.xmland theSitemap:line in/robots.txt. - Use your CMS where possible. WordPress (core since version 5.5, or SEO plugins such as Yoast or Rank Math), Shopify, Wix and Squarespace all generate sitemaps automatically.
- For custom sites, generate dynamically. Build the file from your database so it updates when content changes. Static, hand-made files go stale fast.
- Filter to indexable URLs. Exclude noindexed, redirected, non-canonical and error URLs before output.
- Set honest lastmod dates. Update the date only when the main content changes meaningfully, not when a footer year or sidebar widget changes.
- Validate the file. Open it in a browser, check for XML errors, and crawl it with a tool like Screaming Frog to confirm every URL returns 200 and is self-canonical.
- Submit and reference it. Add it in Search Console and in robots.txt (see below).
How to Submit Your Sitemap
There are two main methods, and we recommend using both.
1. Google Search Console
Open the Sitemaps report, enter the sitemap URL and click Submit. The report shows when Google last read the file, how many URLs it discovered and whether there were fetch or parsing errors. If you are new to the tool, our walkthrough of Google Search Console covers the basics. Bing offers the same function in Bing Webmaster Tools.
2. robots.txt
Add a line anywhere in your robots.txt file. This lets any crawler that reads robots.txt find your sitemap:
User-agent: *
Disallow: /cart/
Sitemap: https://www.example.com/sitemap_index.xml
Not sure how robots.txt interacts with indexing? Our comparison of robots.txt vs meta robots explains the difference.
Monitoring Your Sitemap After Submission
Submitting is the start, not the finish. Check these regularly:
- Sitemaps report status: “Success” means Google could read the file, not that every URL was indexed.
- Page indexing report filtered by sitemap: compare submitted URLs with indexed URLs. A large gap is a diagnostic clue.
- “Crawled – currently not indexed” and “Discovered – currently not indexed”: these often point to quality or crawl-capacity issues rather than sitemap problems. Our guide on fixing “Crawled – currently not indexed” walks through the fixes.
- Last read date: if Google has not fetched the file recently, confirm it is reachable and returns 200.
On very large sites, a lean sitemap also supports efficient crawling. Google's crawl budget guide advises keeping sitemaps up to date and including <lastmod> for updated content. Read more in our post on crawl budget.
Common Mistakes With XML Sitemaps
- Listing non-canonical URLs. Including both
http://andhttps://, or trailing-slash and non-slash versions, muddies canonical signals. - Leaving redirects and 404s in the file. These typically appear after migrations. Regenerate the sitemap whenever URLs change, and see our guides to 301 vs 302 redirects and fixing 404 errors.
- Fake lastmod dates. Setting every URL to today's date teaches Google to distrust the value.
- Blocking the sitemap or its URLs in robots.txt. A sitemap full of disallowed URLs is contradictory.
- Relying on the sitemap instead of internal links. Orphan pages listed only in a sitemap tend to be discovered but treated as low priority.
- Forgetting staging rules. Developers sometimes ship a sitemap that points to a staging domain. Always check the host in
<loc>.
Sitemap Quality Checklist
| Check | Pass condition |
|---|---|
| File reachable | Returns 200 and parses as valid XML |
| Encoding | UTF-8, special characters entity-escaped |
| URL format | Absolute, correct protocol and host |
| URL status | Every URL returns 200 (no redirects or errors) |
| Indexability | No noindex, not blocked by robots.txt, self-canonical |
| Size | Under 50,000 URLs and 50MB uncompressed per file |
| lastmod | Reflects real, significant content changes |
| Discovery | Submitted in Search Console and listed in robots.txt |
Related Guides
- 301 vs 302 Redirects: Which One Should You Use?
- 404 Errors: How to Find and Fix Broken Pages
- Duplicate Content in SEO: Causes and Fixes
Frequently Asked Questions
Does every website need an XML sitemap?
No. Google says small, well-linked sites (roughly 500 pages or fewer) often don't need one. That said, a sitemap is cheap to generate and rarely hurts, so most CMS-driven sites should simply keep one switched on.
Will submitting a sitemap get my pages indexed?
Not on its own. A sitemap helps Google discover URLs, but Google decides what to crawl and index based on quality, duplication and other signals. Pages that are thin or duplicated may still be left out.
Should I use the priority and changefreq tags?
You can leave them out. Google has stated that it ignores both values. Focus on accurate lastmod dates instead.
How many URLs can one sitemap contain?
A single sitemap file can hold up to 50,000 URLs or 50MB uncompressed, whichever comes first. Larger sites split URLs across several sitemaps and list them in a sitemap index file.
Where should my sitemap live?
Usually at the root, such as https://www.example.com/sitemap.xml, because a sitemap generally covers URLs in its own directory and below. Reference it in robots.txt and submit it in Search Console.
How often should my sitemap update?
Ideally automatically, every time you publish, update or delete a page. Most CMS plugins regenerate the file on the fly, which keeps lastmod values honest.
Conclusion
A good XML sitemap is boring in the best way: it lists only your canonical, indexable pages, updates itself automatically and quietly helps search engines find new content quickly. Build it once, check it after every migration or major release, and use Search Console data to spot indexing gaps early. A sitemap check is also a standard step in any SEO audit.
Want a specialist to review your sitemaps, crawlability and indexing? Our SEO team handles technical audits for sites of every size. Get a free quote and we will tell you exactly what is holding your pages back.
References
- Google Search Central: What is a sitemap
- Google Search Central: Build and submit a sitemap
- Google Search Central: Manage your sitemaps with sitemap index files
- Google Search Central: How to specify a canonical URL
- Google Crawling Infrastructure: Large site owner's guide to managing your crawl budget
- Sitemaps.org protocol
- Semrush: XML Sitemap — What It Is and How to Generate One



