TECHNICAL AUDIT

XML Sitemap: What It Is, How to Create One, and What to Check

What an XML sitemap does, what to include and exclude, how to submit it to Google, and how to check it for common errors — with examples for Next.js, WordPress, and static sites.

An XML sitemap tells search engines which pages exist on your site, when they were last updated, and (sometimes) how often they change. It doesn't guarantee indexing and it's not a ranking signal — but it is the most reliable way to ensure Google knows about every URL on your site, especially pages that aren't well-linked internally.

This guide covers what a sitemap does, what to put in it, what to leave out, how to submit it to Google Search Console, and how to check it for the common errors that quietly break it.

What an XML sitemap actually does

A sitemap is a file at a predictable URL (typically /sitemap.xml) that lists URLs for Google to discover and crawl. It does three things:

  1. Discovery: tells Googlebot which URLs exist — critical for pages buried deep in the site hierarchy or not well-linked from other pages.
  2. Freshness signals: the <lastmod> date tells Googlebot when a page was last updated. Accurate <lastmod> values help Googlebot prioritise recrawling recently changed pages.
  3. Crawl prioritisation hint: <priority> and <changefreq> fields exist in the spec but Google's own documentation states it largely ignores them. Set them if your CMS generates them automatically, but don't invest time manually tuning them.

What a sitemap does not do: guarantee indexing (Google decides that based on quality signals), boost rankings (sitemaps are a crawl tool, not a ranking factor), or fix underlying technical issues (a crawlable URL with a noindex tag won't be indexed regardless of the sitemap).

The XML sitemap format

A minimal valid sitemap:

<?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-07-12</lastmod>
  </url>
  <url>
    <loc>https://example.com/blog/my-article</loc>
    <lastmod>2026-06-20</lastmod>
  </url>
</urlset>

The full spec also supports <changefreq> (always, hourly, daily, weekly, monthly, yearly, never) and <priority> (0.0–1.0), but these are advisory and largely ignored by Google in practice.

URL formatting rules:

  • All URLs must be absolute (include the full https:// domain)
  • Use HTTPS URLs if your site is HTTPS (which it should be)
  • URLs must be URL-encoded (spaces → %20, not +)
  • Maximum 50,000 URLs per sitemap file; maximum 50 MB uncompressed

Sitemap index files

For large sites, a sitemap index file points to multiple individual sitemap files:

<?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-07-12</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-blog.xml</loc>
    <lastmod>2026-07-12</lastmod>
  </sitemap>
</sitemapindex>

This is useful when: you have more than 50,000 URLs, you want to separate pages by type (products, blog posts, images), or you want to track indexing separately per section in Google Search Console.

What to include in your sitemap

Include:

  • Canonical URLs for every indexable page (pages without noindex)
  • Your most important landing pages: homepage, key categories, product pages
  • Blog posts and articles
  • Tool and utility pages
  • Static content pages that receive search traffic or that you want to be indexed

Exclude:

  • Pages with <meta name="robots" content="noindex"> — don't list noindex pages in the sitemap; sending Google a noindex URL in the sitemap creates a conflicting signal
  • Paginated URLs (?page=2) unless the paginated content is meaningfully unique
  • URL parameter variants (?sort=price, ?color=blue) — include the canonical base URL, not the filtered variants
  • Staging or development URLs
  • Login-required or paywalled pages that Googlebot can't access
  • Thank-you pages, confirmation pages, cart/checkout pages
  • 301 redirect sources — include the redirect target, not the redirect source
  • 404 and 410 pages

How to create your sitemap

Next.js (App Router)

Create app/sitemap.ts — Next.js auto-serves it at /sitemap.xml:

import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
  return [
    { url: 'https://example.com', lastModified: new Date(), priority: 1 },
    { url: 'https://example.com/blog', lastModified: new Date(), priority: 0.8 },
  ]
}

For dynamic routes (blog posts, product pages), fetch the data and map to sitemap entries within the same function.

WordPress

WordPress generates /sitemap.xml automatically via Yoast SEO, Rank Math, or (since WordPress 5.5) the built-in core sitemap. Verify the sitemap at /sitemap.xml or /wp-sitemap.xml and check that it includes all published post types you want indexed.

Static sites (Astro, Jekyll, Hugo)

Astro: use @astrojs/sitemap integration — add to astro.config.mjs and it auto-generates on build. Hugo: set enableRobotsTXT = true in config.toml and add a sitemap.xml layout. Jekyll: use jekyll-sitemap gem.

Manually / from a spreadsheet

For small sites (under 50 pages), you can write the sitemap XML manually or use a free sitemap generator tool. Just ensure every URL is absolute, uses HTTPS, and is URL-encoded.

How to submit your sitemap to Google Search Console

  1. Open Google Search Console → your property
  2. Go to Indexing → Sitemaps in the left sidebar
  3. Enter your sitemap URL in the "Add a new sitemap" field and click Submit
  4. Google will show a status: Success, Couldn't fetch, or Has errors

Also add a Sitemap: directive to your robots.txt file — this tells any crawler that discovers your robots.txt where to find the sitemap:

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

Common sitemap errors and how to fix them

Non-canonical URLs in sitemap

Problem: The sitemap lists https://example.com/page/ but the canonical tag on that page points to https://example.com/page (without trailing slash), or vice versa. Google sees conflicting signals.

Fix: Ensure every URL in the sitemap matches the canonical tag on that page exactly — same protocol, same trailing slash or no trailing slash, same subdomain. Use the URL from <link rel="canonical"> as the sitemap URL.

Noindex pages listed in sitemap

Problem: Pages with <meta name="robots" content="noindex"> appear in the sitemap. Google has to reconcile a "please index this" (sitemap) with "please don't index this" (meta tag) signal.

Fix: Remove noindex pages from the sitemap. If you're generating the sitemap automatically, filter out any URL with a noindex directive before adding it to the sitemap output.

HTTP URLs in an HTTPS site

Problem: The sitemap lists http://example.com/page but the site redirects to HTTPS. Google must follow the redirect to reach the real URL.

Fix: Always use HTTPS URLs in the sitemap. This should match your canonical tags.

Missing pages

Problem: The sitemap only lists pages the developer remembered to add manually, missing newer content. A blog with 200 posts has 150 missing from the sitemap.

Fix: Generate the sitemap dynamically from your content source — the database, the file system, the CMS API — rather than maintaining it manually. Every content management system has a plugin or module for this.

Sitemap not referenced in robots.txt

Problem: The sitemap exists but has no Sitemap: directive in robots.txt. Googlebot must discover the sitemap through GSC submission only.

Fix: Add Sitemap: https://yourdomain.com/sitemap.xml to the last line of robots.txt.

Last-modified dates are all the same

Problem: Every URL has the same <lastmod> date (the date the sitemap was generated), not the date each page was actually last updated.

Fix: Use the actual last-modified date of each page — from the CMS database, the file modification date, or a manifest. A static lastmod of "today's date" on all URLs is technically valid but provides no useful freshness signal to Googlebot.

How to check your sitemap

Free checks you can do right now:

  1. Fetch the sitemap directly: visit https://yourdomain.com/sitemap.xml in your browser. It should return XML without errors.

  2. Google Search Console Sitemaps report: submit the sitemap if you haven't; the report shows "Discovered URLs" vs "Indexed URLs". A large gap (many discovered but few indexed) usually means content quality issues, not sitemap errors.

  3. Check for noindex conflicts: for any important URL in the sitemap, view its source HTML and confirm there's no noindex meta tag.

  4. Verify canonical alignment: for any URL in the sitemap, check that the <link rel="canonical"> tag on that page points to the exact same URL.

  5. Run a free SEO audit on DeepSEOAnalysis — the technical category includes sitemap validation: whether the sitemap is accessible, whether all crawled pages are present, whether noindex pages are excluded, and whether the Sitemap directive is in robots.txt.


Frequently asked questions

Does an XML sitemap help with rankings?

Not directly. A sitemap is a crawl and discovery tool — it helps Googlebot find your pages, which is a prerequisite for indexing, which is a prerequisite for ranking. A sitemap doesn't make a page rank better; it makes sure the page gets considered for ranking in the first place. If your site is already well-crawled (good internal linking, shallow click depth), a sitemap provides marginal additional benefit. For large sites with deep hierarchies or many new pages, a sitemap is essential.

How often should I update my sitemap?

Update the sitemap whenever you publish, update, or delete pages. For sites with frequent content changes, a dynamically-generated sitemap (regenerated on each request or on each deploy) is better than a static file that needs manual maintenance. The <lastmod> date should reflect when each specific page was last updated, not when the whole sitemap file was regenerated.

How many URLs can a sitemap hold?

A single sitemap file can hold up to 50,000 URLs and must be under 50 MB uncompressed. For larger sites, use a sitemap index file that points to multiple sitemap files — each under the 50,000 URL limit.

Should I include images and videos in my sitemap?

Yes, if images and video content are important for your SEO strategy. Google supports image sitemap extensions and video sitemap extensions that provide additional metadata about media files. For most content sites, this is optional — Google discovers images by crawling your pages. For image-heavy sites (stock photo sites, portfolios), an image sitemap can meaningfully increase image indexation.

Run DeepSEOAnalysis on your own site.

Free, no signup. Technical SEO, Core Web Vitals, structured data, and AI visibility in one report.

Run a free audit →