Over the last couple of months I've had many issues reported with similar themes:
I hope this release can resolve these. It has required replacing much of the underlying logic, please test your sitemaps after upgrading.
The v4 introduces the official concept of 'sources' to your sitemaps.
Every URL within your sitemap will belong to a source. A source will either be a User source or a Application source.
This concept existed before v4 in different forms, v4 aims to clean them up and make working with them much easier.
For full documentation see Sitemap Sources.
Nuxt Sitemap now has a dedicated tab in Nuxt Dev Tools to help you debug.
defineI18nRoute(false) (#126)__i18nTransform: trueSee the updated i18n documentation
Now utilises native route rules. By default will set up SWR rules for 10 minutes.
Learn more on the Sitemap Caching guide.
When creating an API endpoint that returns URLs you should use the new defineSitemapEventHandler function for full TypeScript support.
// api/sitemap.ts
export default defineSitemapEventHandler(() => {
return ['/foo']
})
Previously prerendering was done in a Node context, this will now run in a Nitro context which will provide better consistency between prerender and runtime environments.
Video entries are now supported properly. (#159)
cacheTtl is deprecated, you should use cacheMaxAgeSeconds which is more explicit.inferStaticPagesAsRoutes is deprecated, if you were using this to opt-out of pages, you should use excludeAppSources: trueIf you were using Nuxt hooks to modify the prerendered sitemap, you will need to migrate these to Nitro hooks.
export default defineNuxtConfig({
hooks: {
// old - no longer supported
'sitemap:resolved': function (ctx) {},
'sitemap:output': function (ctx) {}
},
})
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:output', async (ctx) => {
// supported!
})
})
By default, app sources will no longer be included in multi sitemap implementations. You will need to use includeAppSources: true to re-enable it. See Extending App Sources for more information.
sitemap:prerender has been removed. You should use sitemap:resolved instead.trailingSlash and siteUrl has been removed. You should use site config, see Setting Site Config.autoAlternativeLangPrefixes has been removed. If you'd like to set up automatic alternative language prefixes use __i18nTransform.This release took over 40 hours. If technical SEO developer experience in Nuxt is important to you, consider supporting my work on Nuxt SEO.