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:
pnpm i -D @nuxtjs/sitemap
  1. Add it to your modules section in your nuxt.config:
nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/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:

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

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: {
    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