---
name: sitemap
description: Publish an XML sitemap and reference it from robots.txt
---

# Implement sitemap.xml

Publish an XML sitemap at your site root listing canonical URLs of every public page.

## Requirements

- Serve `/sitemap.xml` as valid XML with HTTP 200
- Include canonical `<url><loc>` entries for public pages
- Keep it updated when content is published or removed
- Reference it from `/robots.txt`: `Sitemap: https://example.com/sitemap.xml`

## Example

```xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>https://example.com/</loc></url>
  <url><loc>https://example.com/about</loc></url>
</urlset>
```

For Next.js App Router, generate it with `app/sitemap.ts` exporting a `MetadataRoute.Sitemap`.

## References

- [Sitemaps Protocol](https://www.sitemaps.org/protocol.html)
- [Next.js sitemap docs](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap)
