#1785152d3f56 Thanks @astro-factory! - Fixes the sitemap outputting a URL with an empty path for the homepage (e.g. https://example.com instead of https://example.com/) when trailingSlash is set to "never" or build.format is set to "file"
#16837783c4a6 Thanks @jdevalk! - Improves <lastmod> accuracy in the sitemap index. Each <sitemap> entry in sitemap-index.xml is now stamped with the most recent lastmod of the URLs in the child sitemap it points to, instead of repeating a single global date on every entry. When a child sitemap has no per-URL lastmod, the entry falls back to the lastmod option as before. This gives search engines a per-file freshness signal, so they can tell which child sitemaps actually changed without refetching all of them.
#144714296373 Thanks @Slackluky! - 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.
integrations: [
sitemap({
serialize(item) { th
return item
},
chunks: { // this property will be treated last on the configuration
'blog': (item) => { // will produce a sitemap file with `blog` name (sitemap-blog-0.xml)
if (/blog/.test(item.url)) { // filter path that will be included in this specific sitemap file
item.changefreq = 'weekly';
item.lastmod = new Date();
item.priority = 0.9; // define specific properties for this filtered path
return item;
}
},
'glossary': (item) => {
if (/glossary/.test(item.url)) {
item.changefreq = 'weekly';
item.lastmod = new Date();
item.priority = 0.7;
return item;
}
}
// the rest of the path will be stored in `sitemap-pages.0.xml`
#14285bedc31b Thanks @jdcolombo! - Adds a new configuration option namespaces for more control over XML namespaces used in sitemap generation
Excluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. If your site doesnβt have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.
The namespaces option allows you to configure news, xhtml, image, and video namespaces independently. All namespaces are enabled by default for backward compatibility and no change to existing projects is necessary. But now, you can choose to streamline your XML and avoid unnecessary code.
For example, to exclude the video namespace from your sitemap, set video: false in your configuration:
astro.config.mjs
import { sitemap } from '@astrojs/sitemap';
export default {
integrations: [
sitemap({
namespaces: {
video: false,
// other namespaces remain enabled by default
}
})
]
};
The generated XML will not include the xmlns:video namespace:
#14233896886c Thanks @gouravkhunger! - Fixes the issue with the option lastmod where if it is defined it applies correctly to <url> entries in each sitemap-${i}.xml file but not the <sitemap> entries in the root sitemap-index.xml file.
#136825824b32 Thanks @gouravkhunger! - Adds a customSitemaps option to include extra sitemaps in the sitemap-index.xml file generated by Astro.
This is useful for multi-framework setups on the same domain as your Astro site (example.com), such as a blog at example.com/blog whose sitemap is generated by another framework.
The following example shows configuring your Astro site to include sitemaps for an externally-generated blog and help center along with the generated sitemap entries in sitemap-index.xml:
#1375390293de Thanks @mattyoho! - Customize the filenames of sitemap XML files generated by the @astro/sitemap integration by setting filenameBase in the integration configuration settings. This may be useful when deploying an Astro site at a path on a domain with preexisting sitemap files.
Generated sitemap files will appear at /sitemap-0.xml and /sitemap-index.xml by default, which may conflict with preexisting files. Set filenameBase to a custom value to avoid that if so:
import { defineConfig } from'astro/config';
import sitemap from'@astrojs/sitemap';
exportdefaultdefineConfig({
site: 'https://example.com',
integrations: [
sitemap({
filenameBase: 'astronomy-sitemap',
}),
],
});
This will yield sitemap and index files as https://example.com/astronomy-sitemap-0.xml and https://example.com/astronomy-sitemap-index.xml.