v3.0.0
Features 🚀
🤝 Stable I18n Integration
Fully supporting i18n sites through the sitemap
module has been a long requested feature.
V2 Partially supported it, but in v3 support is fully integrated with build-time macros support and more.
🚀 Default Caching
Caching is now enabled by default for production sitemaps. Sitemaps will be cached for 1 hour.
You can change the cache time or disable caching by setting the cacheTtl
config.
export default defineNuxtConfig({
sitemap: {
cacheTtl: 5 * 60 * 60 * 1000 // 5 hours
}
})
You can also provide your own cache instance by setting the runtimeCacheStorage
config.
export default defineNuxtConfig({
sitemap: {
runtimeCacheStorage: {
driver: 'redis',
host: 'localhost',
port: 6379,
db: 0,
}
}
})
Learn more on the cache guide.
Improved XML Stylesheet
The UI of the sitemap.xml page has been improved slightly. It now features more useful tips and links.
You can also customise the stylesheet with the new following config:
xslTips
- Toggle the tips displayed on the sitemap.xml pages.xslColumns
- Customise the columns displayed on the sitemap.xml pages.
For example, you can change the columns to only show the loc
and lastmod
columns.
export default defineNuxtConfig({
sitemap: {
xslColumns: [
// URL column must always be set, no value needed
{ label: 'URL', width: '75%' },
{ label: 'Last Modified', value: 'sitemap:lastmod', width: '25%' },
],
},
})
Learn more on the Customising the UI guide.
Debug Mode
A debug
config has been added
which will give access to a custom endpoint at /api/__sitemap__/debug
which will show you
how your sitemap is being generated.
When you build your site with debug on, a /__sitemap__/debug.json
page will be generated.
This is disabled by default and should only be enabled for debugging purposes.
Other Improvements
sitemap:output
New Hook:
Type: async (ctx: { sitemap: string; sitemapName: string }) => void | Promise<void>
This will let you modify the string content of the final sitemap before it is returned from the server.
Can be ran in both Nitro (runtime) and Nuxt (prerendering).
sitemap:resolved
New Hook:
Type: async (ctx: { sitemap: FullSitemapEntry[]; sitemapName: string }) => void | Promise<void>
This will let you modify the final sitemap before it is turned into a string.
Can be ran in both Nitro (runtime) and Nuxt (prerendering).
dynamicUrlsApiEndpoint
Individual multi-sitemap API endpoints
- Type:
boolean | string
- Default:
false
You can now give each sitemap a unique API endpoint to fetch URLs from.
export default defineNuxtConfig({
sitemap: {
sitemaps: {
foo: {
dynamicUrlsApiEndpoint: '/api/foo-sitemap'
},
bar: {
dynamicUrlsApiEndpoint: '/api/bar-sitemap'
},
},
}
})
strictNuxtContentPaths
New Config:
- Type:
boolean
- Default:
false
Enable when the paths of your nuxt/content md files match the routing.
This will automatically add sitemap content to the sitemap.
This is similar behaviour to using nuxt/content
with documentDriven: true
.
credits
New Config:
- Type:
boolean
- Default:
true
Allows you to remove the "Generate by Nuxt Sitemap" comment from the generated sitemap.
xslTips
New Config:
- Type:
boolean
- Default:
true
Toggle the tips displayed on the sitemap.xml pages.
Deprecation
trailingSlash
has been deprecatedsiteUrl
has been deprecatedautoAlternativeLangPrefixes
is now disabled by default. If you want to enable it, you need to set it totrue
explicitly.