Sitemap
Getting Started

Install Nuxt Sitemap

Get started with Nuxt Sitemap by installing the dependency to your project.
  1. Install @nuxtjs/sitemap dependency to your project:
npx nuxi@latest module add sitemap
  1. Set Site Config

It's recommended to always set a canonical site URL to avoid duplicate content issues.

You can set your site URL in many ways, the easiest is nuxt.config or .env:

While optional, it's also recommended to set a name as this will be displayed on your sitemap.

export default defineNuxtConfig({
  site: {
    url: 'https://example.com',
    name: 'My Awesome Website'
  },
})

Sitemap URLs will have their trailing slashes removed by default. If you want to keep them, you can set the trailingSlash option to true:

nuxt.config.ts
export default defineNuxtConfig({
  site: {
    // optional: only if you have trailing slashes enabled
    trailingSlash: true
  },
})
  1. Preview your Sitemap

After you've set up the module, if you visit /sitemap.xml you can see the generated sitemap.

This has been generated with Application Sources.

  1. Next Steps