What Is an XML Sitemap? 7 Rules for Building One

An XML sitemap is a file listing the URLs on your site that you want search engines to find, along with extra details about them (last modified date, images, videos, language versions). Google uses this file as a hint to crawl your site more efficiently.
The sitemap problem I see most in technical audits is not missing URLs but clutter: redirected, noindexed or non canonical pages. This article explains what a sitemap does and 7 rules for building one, based on Google's documentation.
Short answer: An XML sitemap is a file that tells Google about the important URLs on your site. A single sitemap can hold up to 50 MB (uncompressed) or 50,000 URLs. Include only canonical URLs you want indexed, keep lastmod accurate and submit the file in Search Console.
What does an XML sitemap do, and does every site need one?
A sitemap makes crawling easier but does not guarantee indexing; Google calls a submitted sitemap merely a hint. According to Google's sitemap documentation, large sites, new sites with few external links and sites with lots of images, video or news content benefit most.
The same documentation says a site with about 500 pages or fewer that is comprehensively linked internally may not need one. Still, most CMSs generate sitemaps automatically, so there is no harm in using one on a small site. For a short definition, see the AI glossary.
An example XML sitemap
In its simplest form, a sitemap looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.examplestore.com/womens-coats/</loc>
<lastmod>2026-10-28</lastmod>
</url>
<url>
<loc>https://www.examplestore.com/womens-coats/quilted-puffer-coat</loc>
<lastmod>2026-11-02</lastmod>
</url>
</urlset>Instead of writing it by hand, use our sitemap generator tool to turn a URL list into a valid XML file.
7 rules for building an XML sitemap
1. Include only canonical URLs you want indexed
A sitemap is your "I want these pages in search" list. Redirected (301), 404, noindexed, robots.txt blocked URLs and URLs that point to another page as canonical do not belong in it. Google generally shows canonical URLs in search results, so list the canonical version. I explain canonical logic in the what is a canonical tag article.
2. Use full, absolute URLs and save the file as UTF-8
Google wants fully qualified URLs including protocol and domain: not `/product-a` but `https://www.example.com/product-a`. The file must be UTF-8 encoded. For URLs with non ASCII characters (such as Turkish letters), make sure they are encoded correctly; ideally avoid them in URLs altogether.
3. Respect the 50 MB and 50,000 URL limits, split when needed
According to Google's documentation, a single sitemap cannot exceed 50 MB uncompressed or 50,000 URLs. On larger sites, split it and use a sitemap index file. One index file can list up to 50,000 sitemaps, and you can submit up to 500 index files per site in Search Console.
- sitemap-categories.xml
- /womens-coats/
- /mens-shoes/
- sitemap-products-1.xml
- /womens-coats/quilted-puffer-coat
- ... up to 50,000 URLs
- sitemap-products-2.xml
- next product URLs
- sitemap-blog.xml
- /blog/how-to-wash-a-coat
Splitting by content type (categories, products, blog) also makes it easier to see in Search Console which section has indexing problems.
4. Keep lastmod accurate and skip priority and changefreq
| Tag | What Google does | Recommendation |
|---|---|---|
| loc | Reads the URL | Required, full URL |
| lastmod | Uses it if consistently and verifiably accurate | Update only on meaningful changes |
| changefreq | Ignores it | No need to add |
| priority | Ignores it | No need to add |
According to Google, a significant change to main content, structured data or links justifies a lastmod update; changing the copyright year does not. Plugins that reset every URL's lastmod to today each night make the signal worthless.
5. Put the sitemap in the root directory
A sitemap can live anywhere on your site, but unless submitted through Search Console it only affects URLs under its own directory. A file at `https://www.example.com/blog/sitemap.xml` does nothing for URLs under `/products/`. That is why Google recommends the root. Sitemaps listed in an index file must also be on the same site and in the index file's folder or below.
6. Submit in Search Console and add it to robots.txt
- Publish the fileCheck that it opens in a browser and returns 200.
- Add it to robots.txtWrite the line Sitemap: https://www.example.com/sitemap_index.xml
- Submit in Search ConsoleEnter the file URL in the Sitemaps report.
- Monitor statusTrack the last read date and processing errors in the report.
Google announced in 2023 that it was deprecating the sitemaps ping endpoint; the options now are Search Console, the Search Console API or robots.txt. Check your robots.txt line with the robots.txt tester, and see the Search Console guide for reading the report.
7. Build image, video and hreflang sitemaps correctly
In an image sitemap, `image:image` and `image:loc` are required for each image; up to 1,000 images can be listed per URL, and tags such as `image:caption` and `image:title` have been removed from Google's documentation. A video sitemap requires a title, description, thumbnail and at least one of `video:content_loc` or `video:player_loc`. See the image SEO and video SEO articles for details.
In an hreflang sitemap, each `url` element must list every language version, including itself, with `xhtml:link`, and the versions must point to each other; otherwise the annotations are ignored. Generate the code with the hreflang generator and review the international setup in the hreflang and international SEO article.
Sitemap checklist before going live
- Every URL returns 200, no redirects or 404s
- No noindexed or robots.txt blocked URLs
- URLs are the canonical version (https, www preference, consistent trailing slash)
- File is UTF-8 and under 50 MB and 50,000 URLs
- lastmod changes only on real updates
- robots.txt has a Sitemap line and the file is submitted in Search Console
I cover how sitemaps affect crawl priority on large sites in the crawl budget article. How to handle old and new sitemaps during a migration is explained in the site migration SEO guide.
Sitemap and technical SEO support
A sitemap is only one part of the technical foundation. To handle crawling, indexing and canonical issues together, read the technical SEO guide or let us review your site as part of SEO consulting. Book a free intro call to get started.
Frequently Asked Questions
I submitted a sitemap but the pages are not indexed. Why?
A sitemap is only a hint; even if Google crawls a URL, it may not index it for quality, duplication or technical reasons. Check the URL with URL Inspection in Search Console and look at the reason in the Page indexing report.
Can I submit a gzip compressed sitemap?
Yes, sitemaps can be served gzip compressed. The 50 MB limit applies to the uncompressed size, though, so compression does not let you exceed it.
How do I create a sitemap in WordPress?
Since version 5.5, WordPress generates a basic sitemap at wp-sitemap.xml automatically. SEO plugins such as Yoast SEO or Rank Math create their own sitemaps; check that the core sitemap is turned off and that you are not submitting both in Search Console.
Is an HTML sitemap the same as an XML sitemap?
No. An HTML sitemap is a page of links built for visitors. An XML sitemap is a machine readable file for search engines. Large sites can use both.
How often should I update my sitemap?
Ideally your CMS updates the sitemap automatically whenever a page is added, removed or significantly changed. Hand built sitemaps go stale quickly and start listing deleted URLs.

8+ years of hands-on SEO and GEO experience across 150+ projects in e-commerce, SaaS, healthcare and local business sectors. Writes based on real client data, not theory.





