Sitemaps · Explainer

XML sitemap best practices

Your sitemap is a direct list of the URLs you want indexed. Keep it to clean, canonical, 200-status pages and it guides crawlers efficiently. Fill it with redirects and errors and it becomes noise. Here's how to do it right.

The one rule that drives every best practice

Your sitemap should list exactly the canonical, indexable, 200-status URLs you want in search, no more, no less. Everything below follows from that.

A sitemap doesn't directly boost rankings, it's a discovery aid that helps search engines find your pages and understand which URLs you consider canonical. That makes it most valuable for large sites, new sites without many backlinks, and deep pages. But its value depends entirely on cleanliness, a sitemap full of non-indexable URLs tells crawlers you want pages indexed that you've also told them not to index. The best practices below all serve the goal of a sitemap that matches your true indexable URL set.

The best practices

Each maps to a real check the audit runs against your sitemap.

Include only clean, indexable URLs

Every URL in the sitemap should be canonical, indexable, and return 200. Exclude redirects, 404s, noindex pages, and non-canonical URLs. The audit flags non-canonical URLs in the sitemap and 3XX (redirect) URLs in the sitemap: both contradict the sitemap's purpose.

Respect the size limits

Maximum 50,000 URLs or 50MB uncompressed per file. For larger sites, use a sitemap index that points to multiple child sitemaps, often split logically (by section, by content type). The audit flags a sitemap that's too large.

Keep lastmod accurate

Provide a truthful lastmod for each URL so crawlers can prioritise genuinely updated pages. Don't stamp every URL with today's date and never use a future date, the audit flags missing lastmod and future-dated lastmod, both of which train crawlers to ignore the field.

Declare it and keep it valid

Reference the sitemap in robots.txt with a Sitemap: line and submit it in Search Console. Make sure it's valid XML and loads quickly, the audit flags sitemap syntax errors and sitemap timeouts. And don't list the same URL in multiple sitemaps; the audit flags pages appearing in multiple sitemaps.

These best practices only cover the standard XML sitemap format. If your site also relies on canonical tags and noindex directives or has structural crawl issues covered under crawlability, fix those first: a technically perfect sitemap can't compensate for pages that are blocked from crawling or excluded from the index by their own tags.

Choosing the right sitemap type

A standard XML sitemap covers most sites. These variants exist for specific content.

Standard XML sitemap

A flat list of <url> entries with <loc> and <lastmod>. The default choice, and what every check on this page assumes unless noted otherwise.

Sitemap index

A <sitemapindex> file listing child sitemap URLs, used once a single file would cross the 50,000-URL or 50MB limit, or to organise a large site by section.

Image sitemap

<image:image> extensions inside existing entries, useful when a lot of your images load lazily or via JavaScript and might otherwise go undiscovered.

Video sitemap

<video:video> extensions carrying title, description and thumbnail, relevant when video is a meaningful part of the page's content.

Whichever type you use, the include/exclude rule above still applies to every entry in it: only reference media and pages tied to canonical, indexable URLs.

Keep the sitemap and your indexable set in sync

The subtle failure isn't a bad URL in the sitemap, it's a good URL missing from it.

Two sets should match, the URLs in your sitemap, and the canonical indexable URLs on your site. When a non-indexable URL sneaks into the sitemap, you send a contradictory signal. When an indexable page is missing from the sitemap, it may be crawled less and discovered later, the audit flags indexable pages not in the sitemap for exactly this reason. It also flags pages dropped from the sitemap since the last crawl, which often signals an accidental removal. Treat the sitemap as a generated reflection of your indexable pages, not a hand-maintained list that drifts out of date.

Common sitemap questions settled

Sitemaps on small sites

A sitemap is still recommended for a small site. It is a low-effort way to ensure discovery and to signal which URLs you consider canonical, and most platforms generate one for you.

That said, a small, well-linked site will mostly be crawled fine without one, because internal links alone are enough for crawlers to reach every page. The value of a sitemap grows with site size and structural depth, so treat it as insurance early on and as genuine infrastructure once the site is large.

Images and video in the sitemap

You can add image and video extensions to a sitemap to aid their discovery, which helps when media is a significant part of what your site offers, such as a product catalogue or a video library.

The core principle still applies: only include media tied to indexable, canonical pages. Listing assets that sit on noindex or non-canonical pages reintroduces the same contradiction the rest of these practices exist to avoid.

How often should the sitemap update?

The sitemap should regenerate whenever pages are added, removed, or change canonical or index status, so it always reflects the current indexable set rather than a past one.

Most platforms generate it dynamically, which makes this automatic. The key is that it stays accurate rather than becoming a stale snapshot: a sitemap regenerated on a schedule that ignores content changes will drift out of sync with the site exactly when the site is changing most.

Generating a sitemap on common platforms

The practices above are the same everywhere; where the sitemap comes from differs by platform.

WordPress (Yoast, Rank Math)

The SEO plugin generates and maintains /sitemap_index.xml for you, splitting by post type. Confirm in the plugin settings that noindexed post types, categories and tags are excluded, since the default configuration doesn't always match what you intend to keep out of search.

Shopify

Shopify generates /sitemap.xml automatically for every store; it isn't editable in the admin. It includes published products, collections, pages and blog posts, and excludes anything unpublished or password-protected without any configuration needed.

Static site generators

Next.js, Astro, Hugo and Jekyll all support generating the sitemap at build time, typically from your route list or content collection via a plugin or a short script. Since it rebuilds on every deploy, accuracy depends on the route list itself reflecting real indexable status.

Custom CMS

Generate the sitemap from the same query or flag your application uses to decide what's indexable, never a separately maintained file. A hand-edited sitemap is the single most common cause of the indexable-pages-missing and noindex-in-sitemap issues the audit flags.

Once the file exists at a stable URL, add a Sitemap: line to robots.txt and submit the same URL in Google Search Console under Sitemaps. Search Console's discovered-versus-indexed counts are a useful cross-check against what a direct crawl of the file finds.

Common sitemap validation errors

What tends to show up once you actually check the file against the protocol.

Best-practice questions, answered

How many URLs can one sitemap hold?

Up to 50,000 URLs or 50MB uncompressed, whichever comes first. These are the sitemaps.org protocol limits, and the audit's oversized-sitemap check flags a file that crosses either one.

Do I need a sitemap index?

Only once a single sitemap would exceed 50,000 URLs or 50MB. Below that, one file is simpler. Above it, a sitemap index lists multiple child sitemaps and you submit the index rather than each child.

Should noindexed pages be in the sitemap?

No. Listing a noindex page in the sitemap contradicts the page's own directive, and the audit flags it as noindex_in_sitemap. Generate the sitemap from the same indexable flag that drives the noindex tag so they can't drift apart.

How do I submit a sitemap to Google?

Add a Sitemap: line to robots.txt with the sitemap's absolute URL, then submit the same URL in Google Search Console under Sitemaps. Search Console reports how many URLs it discovered and how many are indexed.

What's the difference between a sitemap and a sitemap index?

A standard sitemap lists actual page URLs inside <url> elements. A sitemap index lists other sitemap files inside <sitemap> elements instead of pages, purely so a large site can stay under the per-file limit while still exposing one entry point to submit.

Audit your sitemap against your real pages

Free to start. Find redirects, errors, non-canonical URLs and missing pages in your sitemap.

Start my free audit