XML Sitemap Generator: How It Works
An XML sitemap is a list of the URLs you want indexed, offered directly to search engines rather than left to be discovered through links. It does not force indexing, but it removes discovery as an excuse — particularly for large sites, new sites, and pages that few internal links point to.
The format
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/guides/espresso</loc>
<lastmod>2026-08-02</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>| Element | Required | Does it matter? |
|---|---|---|
loc | Yes | Must be absolute and canonical |
lastmod | No | Yes — Google uses it when it is accurate |
changefreq | No | Ignored by Google |
priority | No | Ignored by Google |
Two of the four fields do nothing at Google. lastmod is the exception and is genuinely used — but only if it is honest. Sites that stamp every URL with today's date teach search engines to ignore the field entirely, which loses a real signal for no gain.
What belongs in it
Only canonical, indexable, 200-status URLs. Every one of the following is a mistake:
- URLs that redirect.
- URLs returning 404 or 500.
- Pages carrying
noindex. - Non-canonical duplicates and parameterised variants.
- Pages blocked in robots.txt.
Each contradiction weakens the sitemap's credibility as a whole. A sitemap saying 'index this' alongside a page saying 'do not index me' is a mixed signal, and Search Console reports it as an error.
Limits and splitting
One sitemap holds up to 50,000 URLs or 50 MB uncompressed. Beyond that, split into multiple files and reference them from a sitemap index. Splitting by content type — products, categories, articles — is worth doing well below the limit, because Search Console reports indexing statistics per sitemap, letting you see which section of the site has a problem.
Submitting it
- Reference it in robots.txt:
Sitemap: https://example.com/sitemap.xml. - Submit it in Google Search Console and Bing Webmaster Tools.
- Keep it updated automatically — a stale hand-maintained sitemap is worse than none.
What it will not do
Submitting a URL does not guarantee indexing. Google evaluates whether a page is worth including, and pages judged thin, duplicative or low-value are commonly crawled and then excluded. If Search Console reports 'Discovered — currently not indexed' or 'Crawled — currently not indexed' across many URLs, the sitemap is working and the content is the problem. Adding more URLs will not fix that.
Specialised sitemaps
Image, video and news sitemaps carry extra metadata for those content types. They are worth the effort if images or video are central to your site's search visibility, and unnecessary otherwise. An hreflang sitemap is an alternative to per-page hreflang tags for multilingual sites, and is often easier to maintain at scale.