The generate option is used to tell Nuxt how to generate dynamic routes for a static web app. Dynamic routes are routes that are created by using an underscore in Nuxt. We will cover this type of route in Chapter 4, Adding Views, Routes, and Transitions. We use the generate option with dynamic routes that cannot be detected automatically by the Nuxt crawler if we want to export our Nuxt app as a static web app or as an SPA, instead of using Nuxt as a universal app (SSR). For example, you may have the following dynamic routes (pagination) in your app, if the scrawler fails to detect them:
/posts/pages/1
/posts/pages/2
/posts/pages/3
Then, you can use this generate option to generate and transform the content of each of these routes into an HTML file for you, as follows:
// nuxt.config.js
export default {
generate: {
routes: [
'/posts/pages/1',
'/posts/pages/2',
'/posts/pages/3'
]
}
}
We will show...