Home › Guides › Developer › XML sitemaps explained

XML sitemaps explained

What an XML sitemap is, what Google uses from it, the 50,000 URL and 50 MB limits, and how to avoid the common errors.

By the tools4free.dev team · Last reviewed 4 December 2026

An XML sitemap is a file that lists the URLs on your site that you want search engines to crawl. A single file may hold up to 50,000 URLs and be up to 50 MB uncompressed. Google uses the <loc> address of each entry and, only when it is reliably accurate, the <lastmod> date. It ignores <priority> and <changefreq>. A sitemap helps discovery, but it does not guarantee crawling, indexing or ranking.

What a sitemap is for

Search engines normally find pages by following links. A sitemap gives them a second route: a direct list of addresses. That helps most on large sites, on new sites with few inbound links, and on sites where some pages are poorly linked. On a small site whose pages are all linked from the navigation, a sitemap adds little, though it does no harm and is cheap to keep.

Google describes submission as a hint. It may not download the file or crawl every URL in it. The file also does not override other signals. A URL that is blocked by robots.txt, marked noindex or pointed at a different canonical is not rescued by being listed.

The format

The protocol is documented at sitemaps.org. A minimal file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/products/item-12345</loc>
    <lastmod>2026-12-04</lastmod>
  </url>
</urlset>
TagRequiredWhat Google does with it
<urlset>YesThe root element, with the sitemaps.org namespace.
<url>YesOne entry per page.
<loc>YesThe full, absolute address, exactly as you want it crawled.
<lastmod>NoUsed only if values are consistently and verifiably accurate.
<changefreq>NoIgnored.
<priority>NoIgnored.

Other search engines may treat the optional tags differently, but you gain little by filling them in. A clean file with accurate <loc> and <lastmod> values is the best use of effort.

Limits

Beyond these limits, split the list into several files and link them from a sitemap index, which is a file with a <sitemapindex> root and one <sitemap><loc> entry per child file. The sitemaps.org protocol lets an index list up to 50,000 sitemaps.

Worked example 1: how many files do you need?

A shop has 120,000 product URLs. The count limit applies first: 120,000 / 50,000 = 2.4, so at least three files are needed. Now check the size limit. A typical entry with a <loc> of 39 characters and a <lastmod> measured 106 bytes in Node, including indentation and the line breaks. At that size, 50,000 entries come to 5,300,000 bytes, about 5 MB, nowhere near 50 MB. You could fit roughly 494,000 such entries in 50 MB, so the 50,000 count is the binding limit and the 50 MB limit only matters for entries with very long URLs or extra image and video markup. Three files of 40,000 each work as well as 50,000 + 50,000 + 20,000, and equal parts leave room to grow.

When you split, keep each file in a logical group, such as one for products and one for articles. Search Console reports on each submitted file separately, so a grouped layout makes it quick to see which section has errors or has not been picked up. A sitemap index is itself submitted once, and the child files are found through it.

Escaping and encoding

The five XML special characters must be written as entities inside <loc>: & as &amp;, < as &lt;, > as &gt;, a double quote as &quot; and an apostrophe as &apos;. The ampersand is the one that bites, because query strings use it.

Worked example 2: a URL with a query string

The address https://example.com/search?q=shoes&page=2 must appear in the file as:

<loc>https://example.com/search?q=shoes&amp;page=2</loc>

We confirmed this with a five-character replace function in Node. A raw & makes the XML invalid, and a parser may reject the whole file. Non-ASCII characters in a path should also be percent-encoded as UTF-8, as in /caf%C3%A9, so each address is a valid URL. Our guide to URL structure and percent-encoding covers the details.

What belongs in a sitemap

List the canonical, indexable pages you want in search results. Leave out:

Use one consistent form of each address: the same scheme, the same host (with or without www) and the same trailing-slash style as your canonical tags. Mixed forms send contradictory signals.

lastmod: accuracy matters more than presence

The <lastmod> value uses the W3C date and time format. A plain date such as 2026-12-04 is enough, and a full timestamp such as 2026-12-04T09:30:00+01:00 is also valid. Google says it uses the value only if it is consistently and verifiably accurate, and that it should reflect significant changes to the main content, structured data or links. A changed copyright year or a refreshed footer does not count. Setting every page's <lastmod> to the build date teaches the crawler to ignore the field for your whole site. If you cannot track real edit dates, omit the tag rather than guess.

Telling search engines where it is

Google also accepts RSS 2.0, Atom 1.0 and plain text files with one URL per line. It does not accept an HTML sitemap as a submission, though a human-readable page of links can still help visitors.

Common mistakes

Frequently asked questions

Do I need a sitemap?

Not always. Google says a small, well-linked site may not need one. It is most useful for large, new or poorly linked sites.

Does priority change my ranking?

No. Google ignores <priority> and <changefreq>.

Can the sitemap include other domains?

Generally no. A sitemap should list only URLs on the host where it lives, unless ownership of the other hosts has been verified in Search Console.

How often should I update it?

Whenever the set of pages changes. If it is generated at build time, that happens automatically.

Try it: paste your URLs into the sitemap generator to get a valid, escaped sitemap and a matching robots.txt line. It checks the limits above and runs in your browser.

Sources