# XML sitemap exists and is valid

- **Pattern:** `ab-002511` (`seo-fundamentals.discoverability.sitemap-exists`)
- **Severity:** high
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-002511
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-002511)

## Why it matters

A sitemap gives Googlebot, Bingbot, and AI crawlers an explicit inventory of every URL you want indexed along with each page's last-modified timestamp. Without one, discovery relies entirely on internal linking — which fails for deep routes, newly published pages, and orphaned content. On a new site the sitemap is often the difference between a week and two months before the first crawl. It also speeds reindexing: updating `lastModified` on a page prompts the crawler to revisit, bypassing the standard rediscovery delay.

## Severity rationale

High because missing sitemaps directly delay indexing of new pages and block efficient recrawling on established sites.

## Remediation

In Next.js App Router, export a `sitemap()` function from `app/sitemap.ts`. Iterate your routes programmatically from your CMS or filesystem — do not hand-maintain the list.

```ts
// app/sitemap.ts
export default function sitemap() {
  return [
    { url: 'https://yoursite.com', lastModified: new Date() },
    { url: 'https://yoursite.com/about', lastModified: new Date() },
  ]
}
```

For other frameworks, generate a static `public/sitemap.xml` during build. Submit the URL in Google Search Console once to confirm parsing.

## Detection

- **ID:** `sitemap-exists`
- **Severity:** `high`
- **What to look for:** Check for `public/sitemap.xml` (static) or a route that generates the sitemap (e.g., `app/sitemap.ts` or `app/sitemap.xml/route.ts` in Next.js). Verify the sitemap contains URLs in valid XML format.
- **Pass criteria:** A sitemap file exists (static or generated) containing valid XML with at least 1 `<url>` entry. Count the number of `<url>` entries in the sitemap. The entry count should be no fewer than the number of public page routes in the project.
- **Fail criteria:** No sitemap.xml found, or the sitemap exists but contains 0 URL entries or invalid XML. Report: `"Sitemap has X URLs but project has Y public routes."`
- **Skip (N/A) when:** Never — every public web project benefits from a sitemap.
- **Detail on fail:** `"No sitemap.xml found in public/ directory or as a generated route"` or `"sitemap.xml exists but contains no URL entries"`
- **Remediation:** An XML sitemap helps search engines discover all your pages. In Next.js App Router, create a dynamic sitemap:

  ```ts
  // app/sitemap.ts
  export default function sitemap() {
    return [
      { url: 'https://yoursite.com', lastModified: new Date() },
      { url: 'https://yoursite.com/about', lastModified: new Date() },
      // ... all your pages
    ]
  }
  ```

  Or create a static `public/sitemap.xml` with your pages listed in standard sitemap XML format.

Taxons: findability

HTML version: https://auditbuffet.com/patterns/ab-002511
