Lastmod, Priority, and Changefreq
Introduction
Changing the
If you're using Dynamic URLs, you can modify the data in the
While modifying these in most cases may be unnecessary, see Best Practices, it can be useful when used right.
Setting Defaults
While this is not recommended, in special circumstances you may wish to set defaults for your sitemap entries:
export default defineNuxtConfig({
sitemap: {
defaults: {
lastmod: new Date().toISOString(),
priority: 0.5,
changefreq: 'weekly'
}
}
})
Data Source Merging
You can provide the page you want to set the
export default defineNuxtConfig({
sitemap: {
urls: [
{
loc: '/about',
lastmod: '2023-01-01',
priority: 0.3,
changefreq: 'daily'
}
]
}
})
Modify Loc Data With Route Rules
To change the behaviour of your sitemap URLs, you can use Route rules.
export default defineNuxtConfig({
routeRules: {
// Don't add any /secret/** URLs to the sitemap.xml
'/secret/**': { robots: false },
// modify the sitemap.xml entry for specific URLs
'/about': { sitemap: { changefreq: 'daily', priority: 0.3 } }
}
})
Alternatively, you can use the experimental macro
<script setup>
defineRouteRules({
sitemap: {
changefreq: 'daily',
priority: 0.3
}
})
</script>
Lastmod: Prerendering Hints
When prerendering your site, you can make use of setting the
<script setup>
useSeoMeta({
// will be inferred as the lastmod value in the sitemap
articleModifiedTime: '2023-01-01'
})
</script>