{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.1.json","id":"generators-sitemap","path":"/generators/sitemap","type":"module","module":"generators-sitemap","title":"Sitemap","introducedIn":null,"sourceLink":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `sitemap` generator writes a `sitemap.xml` listing the pages of your site,\nso search engines can find them. Build it next to the\n[website](https://doc-kit.nodejs.org/generators/html) when you publish your\ndocs.","summary":"The `sitemap` generator writes a `sitemap.xml` listing the pages of your site, so search engines can find them. Build it next to the website when you publish your docs.","examples":[],"children":[{"kind":"section","id":"usage","name":"Usage","title":"Usage","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A sitemap lists absolute URLs, so the generator needs your site's address,\n`baseURL`. There is no flag for it, so set it in your configuration file.\n\n```bash\nnpx @doc-kit/cli generate -t html -t sitemap -i \"docs/**/*.md\" -o out\n```\n\nThis writes the site and `out/sitemap.xml`.","summary":"A sitemap lists absolute URLs, so the generator needs your site's address, `baseURL`. There is no flag for it, so set it in your configuration file.","examples":[{"language":"bash","displayName":null,"code":"npx @doc-kit/cli generate -t html -t sitemap -i \"docs/**/*.md\" -o out"}],"children":[]},{"kind":"section","id":"configuring","name":"Configuring","title":"Configuring","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* `indexURL` {string} URL template for the site's index page.\n  **Default:** `'{baseURL}/'`.\n* `pageURL` {string} URL template for each page. `{path}` is the page's path\n  relative to the base of the input glob, with a leading slash and no\n  extension: with `-i \"docs/**/*.md\"`, `docs/guide/intro.md` has the path\n  `/guide/intro`. **Default:** `'{baseURL}{path}.html'`.\n\nBoth are [templates](https://doc-kit.nodejs.org/configuration#generator-options).\nIt also reads the\n[global options](https://doc-kit.nodejs.org/configuration#global-options).\n\nThe default `pageURL` matches the files the website writes\n(`guide/intro.html`). If your host redirects those to extensionless URLs, as\nVercel with `cleanUrls` and Cloudflare Workers do, drop the extension so\nsearch engines don't crawl redirects (see\n[Page URLs](https://doc-kit.nodejs.org/publishing#page-urls)):\n\n```js displayName=\"doc-kit.config.mjs\"\nexport default {\n  sitemap: {\n    pageURL: '{baseURL}{path}',\n  },\n};\n```\n\nFor docs published per version, give each build its own `baseURL`, such as\n`https://docs.example.com/v1.x`, as in\n[Publishing several versions](https://doc-kit.nodejs.org/publishing#publishing-several-versions),\nand both templates point into that version unchanged.","summary":"Both are templates. It also reads the global options.","examples":[{"language":"js","displayName":"doc-kit.config.mjs","code":"export default {\n  sitemap: {\n    pageURL: '{baseURL}{path}',\n  },\n};"}],"children":[]},{"kind":"section","id":"what-the-sitemap-lists","name":"What the sitemap lists","title":"What the sitemap lists","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* One URL for each level-one (`#`) heading in your input, built from\n  `pageURL`. Give each page exactly one `#` heading: a page whose headings all\n  start at `##` is left out, and a page with two `#` headings is listed twice.\n* The index page, built from `indexURL` and added last.\n* With [section pages](https://doc-kit.nodejs.org/generators/section-pages),\n  every section page as well. Add the target to the same run:\n  `-t sitemap -t section-pages`.\n\nEach entry's `<lastmod>` is the day of the build (UTC). Its `<changefreq>` and\n`<priority>` are fixed:\n\n| Entry     | URL from   | `changefreq` | `priority` |\n| --------- | ---------- | ------------ | ---------- |\n| Each page | `pageURL`  | `weekly`     | `0.8`      |\n| The index | `indexURL` | `daily`      | `1.0`      |\n\nFor `docs/guide/intro.md`, with\n`baseURL: 'https://docs.example.com'`, the generator writes:\n\n```xml displayName=\"out/sitemap.xml\"\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n<url>\n  <loc>https://docs.example.com/guide/intro.html</loc>\n  <lastmod>2026-10-26</lastmod>\n  <changefreq>weekly</changefreq>\n  <priority>0.8</priority>\n</url>\n<url>\n  <loc>https://docs.example.com/</loc>\n  <lastmod>2026-10-26</lastmod>\n  <changefreq>daily</changefreq>\n  <priority>1.0</priority>\n</url>\n\n</urlset>\n```","summary":"Each entry's `<lastmod>` is the day of the build (UTC). Its `<changefreq>` and `<priority>` are fixed:","examples":[{"language":"xml","displayName":"out/sitemap.xml","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n<url>\n  <loc>https://docs.example.com/guide/intro.html</loc>\n  <lastmod>2026-10-26</lastmod>\n  <changefreq>weekly</changefreq>\n  <priority>0.8</priority>\n</url>\n<url>\n  <loc>https://docs.example.com/</loc>\n  <lastmod>2026-10-26</lastmod>\n  <changefreq>daily</changefreq>\n  <priority>1.0</priority>\n</url>\n\n</urlset>"}],"children":[]}]}