# Missing or invalid sitemap.xml

> Without a sitemap, search engines discover pages the slow way. Generate a /sitemap.xml listing your URLs and reference it from robots.txt.

_Category: Search visibility · Detector `seo` · Check `sitemap-missing` · Severity: warning_

A sitemap hands search engines a machine-readable list of your URLs plus last-modified dates, so they index new and updated pages faster and more completely. Without one, crawlers have to discover every page by following links, which misses orphaned pages and slows indexing. Client-rendered SPAs are hit hardest because there are few crawlable links to follow.

## Symptoms

- `/sitemap.xml` returns a `404` or your SPA’s `index.html`
- New pages take a long time to appear in search
- Search Console reports no submitted sitemap
- Orphaned pages (no inbound links) never get indexed

## How VibeCheck detects it

The `seo` detector flags this live in the browser and reports it to the widget's Problems list — and to your coding agent over MCP.

- **Issue string:** `Missing or invalid sitemap.xml`
- **Threshold:** /sitemap.xml is not a 2xx XML response

## Root causes

- No sitemap is generated at build or request time
- The SPA dev server returns `index.html` for `/sitemap.xml`, so it is not real XML
- The sitemap exists but is not referenced from `robots.txt`

## The fix

Generate a `/sitemap.xml` that lists every indexable URL with a `<loc>` and ideally a `<lastmod>`. Serve it with an XML content type, keep it under 50,000 URLs / 50MB per file (split with a sitemap index if larger), and reference it from `robots.txt`.

### Steps

1. Generate an XML sitemap of your indexable URLs at build or request time
2. Serve it at `/sitemap.xml` with an `application/xml` content type
3. Add a `Sitemap:` line to `robots.txt` and submit it in Search Console

_sitemap.xml_

```xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://acme.com/</loc>
    <lastmod>2026-01-15</lastmod>
  </url>
  <url>
    <loc>https://acme.com/pricing</loc>
  </url>
</urlset>
```

## Framework-specific fixes

### React

A Vite SPA has no server, so generate the sitemap at build time (a script or a plugin like `vite-plugin-sitemap`) and emit it into the static output.

```bash
npm i -D vite-plugin-sitemap
# configure it in vite.config.ts with your route list
```

### Next.js

Add `app/sitemap.ts` exporting a default function that returns a `MetadataRoute.Sitemap` array. Next serves it at `/sitemap.xml` with the right content type; make it dynamic to include data-driven routes.

_app/sitemap.ts_

```ts
import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
  return [
    { url: 'https://acme.com/', lastModified: new Date() },
    { url: 'https://acme.com/pricing' },
  ]
}
```

[Next.js docs](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap)

### Svelte

Create a SvelteKit endpoint that returns XML with the correct content type.

_src/routes/sitemap.xml/+server.ts_

```ts
export async function GET() {
  const urls = ['https://acme.com/', 'https://acme.com/pricing']
  const body = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map((u) => `  <url><loc>${u}</loc></url>`).join('\n')}
</urlset>`
  return new Response(body, { headers: { 'Content-Type': 'application/xml' } })
}
```

### Vanilla JS

Write a static `sitemap.xml` into your public directory, or generate it in a build step.

```bash
public/sitemap.xml   # served at /sitemap.xml
```

## FAQ

### Do small sites need a sitemap?

A well-linked small site can be crawled without one, but a sitemap still speeds up discovery of new and updated pages and is essential for SPAs with few crawlable links.

### Why does VibeCheck flag my sitemap as invalid?

The probe treats `/sitemap.xml` as missing unless it responds 2xx with an XML content type. A SPA dev server returning `index.html` for unknown paths reads as “not a real sitemap”.

### Should I reference the sitemap in `robots.txt`?

Yes. Add a “`Sitemap: https://acme.com/sitemap.xml`” line to `robots.txt` so crawlers find it even before you submit it in Search Console.

## Related problems

- [Missing robots.txt](https://vibecheck.wcgw.fun/fix/missing-robots-txt.md) — Search visibility
- [Unfriendly URL slug](https://vibecheck.wcgw.fun/fix/unfriendly-url-slug.md) — Search visibility
- [Content only renders with JavaScript](https://vibecheck.wcgw.fun/fix/content-requires-javascript.md) — AI readiness
- [Missing canonical link](https://vibecheck.wcgw.fun/fix/missing-canonical-url.md) — Search visibility

---

Fix guide from VibeCheck — https://vibecheck.wcgw.fun/fix/missing-sitemap. Full site index for LLMs: https://vibecheck.wcgw.fun/llms.txt
