# Missing or invalid sitemap.xml in Svelte

> How to fix missing or invalid sitemap.xml in Svelte — with the exact fix and copy-paste code.

_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.

## The fix for 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' } })
}
```

### 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

## 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

## 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.

See the general, framework-agnostic fix: https://vibecheck.wcgw.fun/fix/missing-sitemap.md

---

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