Rankwell

XML sitemaps: how to build and submit one

What belongs in an XML sitemap, the size limits, when to split it with a sitemap index, honest lastmod dates, and how to submit it to Google.

3 October 2026 · 4 min read

An XML sitemap is a list of the URLs on your site that you want search engines to know about. It does not make pages rank, and it does not force anything into the index. What it does is help crawlers find pages, notice when they change, and tell you, through Search Console, which of them Google decided to keep.

What a sitemap looks like

The smallest valid sitemap:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://yoursite.com/</loc>
    <lastmod>2026-09-28</lastmod>
  </url>
  <url>
    <loc>https://yoursite.com/pricing</loc>
    <lastmod>2026-08-14</lastmod>
  </url>
</urlset>

Each <url> needs a <loc>: the full, absolute URL, including https://. Everything else is optional.

The file must be UTF-8. Characters such as & in a URL have to be escaped, so ?a=1&b=2 is written ?a=1&amp;b=2. An unescaped ampersand makes the whole file invalid XML, and some readers will reject all of it.

You may see <priority> and <changefreq> in older sitemaps. Google ignores both, so there is no need to generate them.

Which URLs belong in it

The sitemap is a statement of which URLs you consider the real, indexable versions of your pages. Every URL in it should:

  • return a 200 status, not a redirect or a 404
  • not carry a noindex tag
  • be the canonical URL, not a variant with tracking parameters or a different trailing slash
  • not be blocked by robots.txt

A sitemap full of redirects, noindex pages and duplicates sends mixed signals. If your sitemap names one URL and your canonical tag names another, Google has to guess, and it may not guess your way.

Leave out internal search results, filtered listings, cart and account pages, and thin tag archives.

How to create one

Most platforms generate a sitemap for you. WordPress has one built in at /wp-sitemap.xml, and SEO plugins usually replace it with their own. Shopify, Squarespace and Wix publish one automatically. Frameworks such as Next.js, Astro and Nuxt have a built-in route or an official plugin that builds it from your pages.

If you have to write one yourself, generate it from the same source as your pages, such as the database or the content folder, rather than keeping a hand-written list. A hand-written sitemap goes stale the first time someone adds a page and forgets to update it.

Whatever produces it, open the result in a browser and read through it. Generated sitemaps often include things nobody intended: attachment pages, test posts, staging URLs, or every tag on the site.

Size limits and the sitemap index

One sitemap file can hold at most 50,000 URLs and must be no larger than 50MB uncompressed. You can serve it gzipped (sitemap.xml.gz) to save bandwidth, but the 50MB limit applies to the uncompressed size.

Beyond that, split the list into several sitemaps and tie them together with a sitemap index:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://yoursite.com/sitemap-pages.xml</loc>
    <lastmod>2026-09-28</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://yoursite.com/sitemap-products-1.xml</loc>
    <lastmod>2026-10-02</lastmod>
  </sitemap>
</sitemapindex>

An index can list up to 50,000 sitemaps, and you submit only the index.

Splitting is useful even below the limits. Separate sitemaps for products, articles and category pages mean Search Console reports indexing for each group on its own, so a drop in indexed products is visible instead of hidden in a site-wide total.

Keep lastmod honest

<lastmod> is the date the page's content last changed in a meaningful way. Google has said it uses lastmod only when it is consistently and verifiably accurate.

The common mistake is generating every lastmod as today's date, or as the time the sitemap was built. When every page claims to have changed today, the dates carry no information, and crawlers learn to ignore them. Then, when an important page really does change, the signal is lost.

What counts as a change:

  • yes: rewritten text, new sections, updated prices or specifications
  • no: a new copyright year in the footer, a changed sidebar, a rebuild of the site with identical content

Use the full date (2026-09-28), or a full date and time with a timezone (2026-09-28T14:30:00+01:00). Store the real modified date with each page and output that. If your CMS cannot tell a content edit from a layout change, leaving lastmod out is better than filling it with dates that are wrong.

Accurate dates also matter for AI answers, as covered in the AI search readiness guide.

Submitting it to Google

There are two ways, and it is worth doing both.

Search Console. Open the Sitemaps report, enter the sitemap or index URL, and submit. Google fetches it and reports whether it could read it and how many URLs it found. Later, the Pages report can be filtered by sitemap to show which of those URLs are indexed and why the others are not. Why Google is not indexing your page explains each reason it may give.

robots.txt. Add a line with the full URL:

Sitemap: https://yoursite.com/sitemap.xml

Every crawler that reads robots.txt, including Bing and the AI crawlers, finds the sitemap this way without you submitting it anywhere. For Bing, you can also submit it in Bing Webmaster Tools.

You do not need to resubmit after each change. Google rereads known sitemaps on its own schedule.

A page that appears only in the sitemap, with no internal links pointing at it, is an orphan. Google may crawl it, but it has little reason to treat it as important, and these pages often end up as "Discovered, currently not indexed". Link to every page you care about from somewhere on the site, as covered in internal links, the free ranking factor.

Rankwell's site audit reads your sitemap, including sitemap indexes, and compares it with what it finds by following links, so pages that exist only in the sitemap are listed separately.

Common questions

Do I need a sitemap if my site is small?
Not strictly. Google says a small site whose pages are all well linked may not need one. It still costs little, helps new pages get found sooner, and gives you useful reports in Search Console.
Does Google use priority and changefreq?
No. Google ignores both. It uses lastmod when the dates are consistently accurate, and the list of URLs itself.
Can I still ping Google when my sitemap changes?
No. Google retired its sitemap ping endpoint in 2023. Keep lastmod accurate and Google will pick up changes when it rereads the sitemap.

Read next