Nuxt.js Add Sitemap for Static Site Generate

Mar 27, 2020

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:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.