Skip to content

Feature(sitemap): named files chunking strategy#1

Merged
Slackluky merged 7 commits intomainfrom
feature/sitemap-chunking-strategy
Oct 1, 2025
Merged

Feature(sitemap): named files chunking strategy#1
Slackluky merged 7 commits intomainfrom
feature/sitemap-chunking-strategy

Conversation

@Slackluky
Copy link
Owner

@Slackluky Slackluky commented Oct 1, 2025

Changes

New sitemap optional configuration for named sitemap files chunking strategy

Adds a chunks option to the sitemap configuration schema.
This allows users to define custom chunking strategies for
generating sitemaps, providing flexibility in how the sitemap
is split into multiple files.

			integrations: [
				sitemap({
					serialize(item) {
						return item
					},
					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 = 'weekly';
								item.lastmod = new Date();
								item.priority = 0.9;
								return item;
							}
						}
					},
				}),
			],

Testing

image image

Docs

yes, to add optional configurations for the chunks

cc @withastro/maintainers-docs for feedback!

Adds the ability to split sitemap generation into chunks based on
customizable logic. This allows for better management of large
sitemaps and improved performance.

The new `chunks` option in the sitemap configuration allows users to
define functions that categorize sitemap items into different chunks.
Each chunk is then written to a separate sitemap file.

This change introduces a new `writeSitemapChunk` function to handle
the writing of individual sitemap chunks.
Adds a `chunks` option to the sitemap configuration schema.
This allows users to define custom chunking strategies for
generating sitemaps, providing flexibility in how the sitemap
is split into multiple files.
The empty callback function in the `writeSitemap` function was
causing unnecessary function calls. This commit fixes this by
removing the empty callback.
This commit adds a test fixture to verify the sitemap chunking
functionality. It includes a configuration file, dependencies,
and several pages to simulate a real-world scenario.
Adds changeset to document the new sitemap chunking feature.
This feature allows splitting sitemap generation into chunks
based on customizable logic, improving management of large
sitemaps and performance.
@Slackluky Slackluky merged commit 9687b55 into main Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant