Nuxt Prerendering
Introduction
When prerendering routes using Nuxt through either
This can be useful if you have dynamic routes that you want to be included in the sitemap and want to minimise your configuration.
Extracted HTML Data
The following data can be extracted from the raw HTML.
images - Adds image entries<image:image> .
Passes any
videos - Adds video entries<video:video> .
Passes any
lastmod - Adds lastmod date<lastmod> .
Uses the opengraph
Enabling Nuxt Prerendering
You will need to use configuration to enable this feature.
export default defineNuxtConfig({
nitro: {
prerender: {
// enabled by default with nuxt generate, not required
crawlLinks: true,
// add any routes to prerender
routes: ['/']
}
}
})
You can also use route rules to enable prerendering for specific routes.
export default defineNuxtConfig({
routeRules: {
'/': { prerender: true }
}
})
Prerendering the Sitemap on Build
If you're using
export default defineNuxtConfig({
nitro: {
prerender: {
routes: ['/sitemap.xml']
}
}
})