diff --git a/src/content/docs/en/guides/integrations-guide/sitemap.mdx b/src/content/docs/en/guides/integrations-guide/sitemap.mdx index 3e5dfdc924389..6a4a5ac79dd74 100644 --- a/src/content/docs/en/guides/integrations-guide/sitemap.mdx +++ b/src/content/docs/en/guides/integrations-guide/sitemap.mdx @@ -395,7 +395,59 @@ export default defineConfig({ }); ``` -### `i18n` +### `chunks` + +

+ +**Type:** `Record SitemapItem | undefined>` + +

+ +A map of functions that allows you to split your sitemap into multiple files based on custom logic. Each key in the object becomes the name of a separate sitemap file, and its corresponding function determines which URLs will be included in that chunk. This can be useful for instance if a specific section of your website changes very often and you'd like to specify a different change frequency for its entries. + +Each chunk function receives a `SitemapItem` and for each item returns either: +* the modified `SitemapItem`, if the URL should be included in this chunk +* `undefined`, if the URL should not be included in this chunk + +The example below shows how to split URLs into different sitemap files based on their path: + +```js title="astro.config.mjs" ins={8-25} +import { defineConfig } from 'astro/config'; +import sitemap from '@astrojs/sitemap'; + +export default defineConfig({ + site: 'https://example.com', + integrations: [ + sitemap({ + chunks: { + 'blog': (item) => { + if (/blog/.test(item.url)) { + item.changefreq = 'weekly'; + item.lastmod = new Date(); + item.priority = 0.9; + return item; + } + }, + 'glossary': (item) => { + if (/glossary/.test(item.url)) { + item.changefreq = 'monthly'; + item.lastmod = new Date(); + item.priority = 0.7; + return item; + } + } + }, + }), + ], +}); +``` + +This configuration will generate the following files: + +- `sitemap-blog-0.xml` +- `sitemap-glossary-0.xml` + +URLs that don't match any chunk will be placed in a default `sitemap-pages-0.xml` file.