webtrajans
en

XML sitemaps: format, limits and how to fix common errors

A sitemap is a list of the URLs you want search engines to know about. It doesn't guarantee indexing, but a clean one helps crawlers find new and updated pages faster.

Updated: 5 min read

An XML sitemap is a machine-readable list of the pages on your site that you want search engines to crawl and index. Search engines can discover pages by following links, but a sitemap helps them find new, deep or poorly linked pages sooner and tells them when content changed. Most CMSs generate one automatically (WordPress core, Yoast, Rank Math, Shopify, Wix), but automatically generated doesn’t always mean correct.

Basic format

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-10-01</lastmod>
  </url>
  <url>
    <loc>https://example.com/services/web-design/</loc>
    <lastmod>2026-09-14</lastmod>
  </url>
</urlset>
  • <loc> is required: an absolute URL, including protocol, exactly as the canonical version appears (same https, same www or non-www, same trailing slash).
  • <lastmod> is optional but useful, in W3C date format (2026-10-01 or with time and timezone). Only update it when the content meaningfully changes.
  • <priority> and <changefreq> are ignored by Google, so you can leave them out.
  • The file must be UTF-8 encoded, and special characters in URLs must be escaped (& becomes &amp;).

Limits and sitemap index files

Each sitemap file can hold up to 50,000 URLs and must be no larger than 50 MB uncompressed. You may gzip it to save bandwidth, but the limit applies to the uncompressed size. Above that, split the sitemap and create an index:

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

Splitting by type (pages, posts, products, categories) is useful even below the limit, because Search Console then shows indexing statistics per sitemap and you can spot which section has problems.

What belongs in a sitemap (and what doesn’t)

Include: canonical, indexable URLs returning 200, the pages you’d want a visitor to land on from search.

Exclude:

  • redirected URLs (3xx) and broken ones (4xx/5xx),
  • pages with noindex,
  • non-canonical duplicates (parameter variants, print versions, session IDs),
  • URLs blocked by robots.txt,
  • thin utility pages: cart, checkout, login, internal search results.

A sitemap full of redirects and noindexed pages sends mixed signals and makes Search Console reports harder to read.

Hreflang in sitemaps

For multilingual or multi-regional sites you can declare language alternates inside the sitemap instead of in each page’s <head>:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/en/pricing/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/pricing/"/>
    <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/preise/"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/en/pricing/"/>
  </url>
</urlset>

Every language version must list all alternates, including itself, and the references must be reciprocal. Missing return links are the most common hreflang error.

Submitting your sitemap

  1. robots.txt: add an absolute Sitemap: line. Any crawler that reads robots.txt will find it.
Sitemap: https://example.com/sitemap_index.xml
  1. Google Search Console: Indexing → Sitemaps → enter the URL → Submit.
  2. Bing Webmaster Tools: Sitemaps → Submit sitemap. Bing also supports IndexNow for instant change notifications.

Google retired its old anonymous sitemap “ping” endpoint in 2023, so use robots.txt and Search Console instead. Our robots.txt tester confirms the sitemap line is present and the sitemap URL itself isn’t blocked.

Image, video and news sitemaps

Google supports extensions to the standard format for specific content:

  • Image sitemaps list images that appear on a page with <image:image> and <image:loc>. Useful when images are loaded by JavaScript or hosted on a CDN domain, so crawlers might not otherwise find them.
  • Video sitemaps describe videos with a title, description, thumbnail and duration. Many sites now rely on VideoObject structured data instead, but a video sitemap is still supported.
  • News sitemaps are for publishers approved for Google News and should only contain articles published in the last two days.

These extensions can live inside your normal sitemap files or in separate ones listed in the same sitemap index.

How often should the sitemap update?

Ideally, automatically, every time content is published, updated or removed. Static site generators and most CMS plugins regenerate it on build or on save. Avoid hand-maintained sitemaps on anything bigger than a handful of pages: they drift out of date quickly, and stale entries (deleted pages, old URLs) are exactly what produces errors in Search Console.

Common errors and fixes

Error Likely cause Fix
Couldn’t fetch Pending processing, or sitemap URL blocked, 404, behind a login or firewall/WAF Wait a day for new submissions; then test the URL from outside, check robots.txt and bot protection
Sitemap is HTML URL returns a web page (e.g. a 404 page with status 200) Submit the real XML URL
Invalid date lastmod not in W3C format Use YYYY-MM-DD or full ISO 8601 with timezone
URLs not followed / redirects Old HTTP or non-www URLs listed List final canonical URLs only
Submitted URL marked noindex Template or plugin conflict Remove from sitemap or fix the noindex
Too many URLs Over 50,000 in one file Split and use a sitemap index

Security plugins and CDN bot protection are a frequent hidden cause of “Couldn’t fetch”: they challenge Googlebot with a JavaScript check it can’t pass. Use our sitemap checker to fetch the file as an external client and validate the structure and URL count.

Checklist

  • Sitemap returns 200, valid XML, UTF-8, under 50,000 URLs and 50 MB per file.
  • Only canonical, indexable 200 URLs; no redirects, 404s or noindexed pages.
  • lastmod reflects real content changes.
  • Sitemap listed in robots.txt and submitted in Search Console and Bing Webmaster Tools.
  • Hreflang alternates, if used, are complete and reciprocal.
  • Recheck after migrations, CMS updates and URL structure changes. See also our robots.txt guide.

Frequently asked questions

How many URLs can a sitemap contain?

Up to 50,000 URLs and 50 MB uncompressed per file. Larger sites split URLs across several sitemaps and list them in a sitemap index file.

Do I need a sitemap for a small website?

Not strictly. Google says small, well-linked sites of up to around 500 pages may not need one, but a sitemap is free to generate and helps with new pages, images and Search Console reporting.

Does Google use priority and changefreq?

No. Google ignores the priority and changefreq values. It does use lastmod if the dates are consistently accurate.

Why does Search Console say Couldn't fetch?

Often it's just pending: the status can show for new submissions before Google processes them. If it persists, check that the sitemap URL returns 200, isn't blocked by robots.txt or a firewall, and is valid XML.

Related guides