Go to documentation

Simple, minimal sitemap.xml generation.


NPM versionNPM DownloadsGitHub stars

A simple sitemap.xml module for Nuxt 3.

Status: v1 Stable
Please report any issues 🐛
Made possible by my Sponsor Program 💖
Follow me @harlan_zw 🐦 • Join Discord for help

ℹ️ Looking for a complete SEO solution? Check out Nuxt SEO Kit.


  • 🪝 Minimal config, powerful API
  • 🔄 Route config using route rules
  • 🏞️ Handle trailing slashes
  • 📦 Uses sitemap.js


npm install --save-dev nuxt-simple-sitemap# Using yarnyarn add --dev nuxt-simple-sitemap



export default defineNuxtConfig({  modules: [    'nuxt-simple-sitemap',  ],})

Set host

You'll need to provide the host of your site in order to generate the sitemap.xml.

export default defineNuxtConfig({  // Recommended   runtimeConfig: {    public: {      siteUrl: process.env.NUXT_PUBLIC_SITE_URL || '',    }  },  // OR   sitemap: {    hostname: '',  },})


Handling dynamic routes

By default, all static routes are included within the sitemap.xml

To enable dynamic routes to be included, you can either manually provide them via the urls config or enable the Nitro crawler.

If your dynamic links are linked on your site, you can enable the Nitro crawler to automatically include them.

This is recommended as having internal links for all your pages is a good practice for SEO.

export default defineNuxtConfig({  nitro: {    prerender: {      crawlLinks: true,      routes: [        '/',      ]    }  }})

Manual dynamic URLs

export default defineNuxtConfig({  sitemap: {    // provide dynamic URLs to be included     urls: async () => {      const blogPages = await getBlogPages()      return => ({          url: `/blog/${page.slug}`,          lastmod: page.updatedAt,          changefreq: 'daily',          priority: 0.8,      }))    },  },})

Configure sitemap.xml entries

To change the behavior of sitemap.xml entries, you can use Nitro route rules.


export default defineNuxtConfig({  routeRules: {    // Don't add any /secret/** URLs to the sitemap.xml      '/secret/**': { index: false },    // modify the sitemap.xml entry for specific URLs    '/about': { sitemap: { changefreq: 'daily', priority: 0.3 } }  }})

See for all available options.

Previewing sitemap

In development, you can visit /sitemap.preview.xml.

If you're using the Nitro crawler, this sitemap.xml will only be a preview, as the dynamic URLs won't be resolved.

Module Config

If you need further control over the sitemap.xml URLs, you can provide config on the sitemap key.


  • Type: string
  • Default: undefined
  • Required: true

The host of your site. This is required to generate the sitemap.xml. Example:


  • Type: boolean
  • Default: false

Whether to add a trailing slash to the URLs in the sitemap.xml.


  • Type: boolean
  • Default: true

Whether to generate the sitemap.xml.


  • Type: object
  • Default: {}

Default values for the sitemap.xml entries. See for all available options.


  • Type: () => MaybePromise<SitemapEntry[]> | MaybePromise<SitemapEntry[]>
  • Default: []

Provide custom URLs to be included in the sitemap.xml.


  • Type: string[]
  • Default: ['/**']

Filter routes that match the given rules.

export default defineNuxtConfig({  sitemap: {    include: [      '/my-hidden-url'    ]  }})


  • Type: string[]
  • Default: undefined

Filter routes that match the given rules.

export default defineNuxtConfig({  sitemap: {    exclude: [        '/my-secret-section/**'    ]  }})

Additional config extends sitemap.js.


  • Type: boolean
  • Default: true

Whether to generate the sitemap.xml preview in development. It can be useful to disable if you have fetch requests to external APIs.


  • Type: boolean
  • Default: true

Will generate routes from your static page files. Useful to disable if you're using the i18n module with custom routes.


Add custom routes without pre-rendering

export default defineNuxtConfig({  hooks: {      'sitemap:generate': (ctx) => {          // add custom URLs          ctx.urls.push({              url: '/my-custom-url',              changefreq: 'daily',              priority: 0.3          })      }  }})



MIT License © 2022-PRESENT Harlan Wilton