Install
npm install @nuxtjs/sitemap
Edit nuxt.config.js
export default { modules: [ '@nuxtjs/sitemap' ], sitemap: { hostname: 'https://covid-19.luasoftware.com/', // gzip: true, },}
NOTE: I have already setup generate.routes for static pages generation, so sitemap will use it by default.
NOTE: There are extra features to exclude or filter routes, or separate sitemap files.
Generate static pages
npm run generate
The static file is generated at dist/sitemap.xml
, and can be accessed via /sitemap.xml
.
NOTE: If you are using runtime server side render (SSR), I believed /sitemap.xml
will be generated at runtime.
References: