How to stop nuxt generate to crawl links

Nuxt generate will look for all <a> tags and follow their href to generate them. How to stop this?
2 Replies
kapa.ai
kapa.ai3d ago
Hi @NightFuries. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To stop Nuxt from crawling links during the nuxt generate process, you can configure the nitro.prerender options in your nuxt.config.ts file. Here's how you can do it: 1. Set crawlLinks to false to disable automatic link crawling:
export default defineNuxtConfig({
nitro: {
prerender: {
crawlLinks: false
}
}
})
export default defineNuxtConfig({
nitro: {
prerender: {
crawlLinks: false
}
}
})
2. Optionally, you can specify the exact routes you want to prerender:
export default defineNuxtConfig({
nitro: {
prerender: {
routes: ['/user/1', '/user/2']
}
}
})
export default defineNuxtConfig({
nitro: {
prerender: {
routes: ['/user/1', '/user/2']
}
}
})
3. If you want to exclude specific routes from being prerendered, you can use the ignore option:
export default defineNuxtConfig({
nitro: {
prerender: {
ignore: ['/dynamic']
}
}
})
export default defineNuxtConfig({
nitro: {
prerender: {
ignore: ['/dynamic']
}
}
})
By configuring these options, you can control which routes are prerendered and prevent Nuxt from automatically crawling all links. For more detailed information on prerendering configuration, you can refer to the Nuxt documentation on Prerendering (https://nuxt.com/docs/getting-started/prerendering). Nuxt documentation on Prerendering (https://nuxt.com/docs/getting-started/prerendering) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@711113525023735809> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?