# sitemap.xml

> The `sitemap.xml` is a file that lists the pages of a website, helping search engines understand its structure and index it more efficiently.

## How do I create a sitemap.xml for my website?

The XML file that outlines the structure of a website and provides search engines with information about pages, videos and other resources to improve crawling and indexing.

- Topic: Search Engine Optimization
- Type: file

## Example

Wrong:

```xml
<urlset>
  <url><loc>/blog/post-1</loc><priority>1.0</priority></url>
</urlset>
```

Right:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/blog/post-1</loc>
    <lastmod>2026-03-10</lastmod>
  </url>
</urlset>
```

Locations must be absolute URLs and the namespace is required, while `priority` is mostly ignored.

## Common mistakes

- Setting every `lastmod` to the deploy date, so search engines learn to ignore it.

## Key points

- URLs are absolute and canonical and return 200, with no redirects or `noindex` pages.
- Each file has at most 50,000 URLs and 50 MB uncompressed, and larger sites use a sitemap index.
- `lastmod` reflects real content changes, not the build time of every deploy.
- The sitemap is listed in `robots.txt` with a `Sitemap:` line.

## Interview questions

### Do I need a sitemap for a small site?

Not usually. Crawlers find well-linked pages on their own, but a sitemap still helps new sites and pages with few links.

### Do changefreq and priority matter in a sitemap?

Mostly not. Some search engines ignore them entirely, and an accurate `lastmod` matters more.

### How do I submit a sitemap to search engines?

Add a `Sitemap:` line to `robots.txt` and submit the URL in each search engine's webmaster tools.

## Related cards

- [robots.txt](https://wonderium.dev/web/robots-txt.md)
- [Crawler](https://wonderium.dev/web/crawler.md)
- [SEO](https://wonderium.dev/web/seo.md)
- [.xml](https://wonderium.dev/engineering/xml.md)
- [URL](https://wonderium.dev/web/url.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/sitemap-xml
- Last updated: 2026-11-25
