Index of every page on this site: llms.txt

Introduction

By default, the module generates a single /sitemap.xml file, which works perfectly for most websites.

For larger sites with thousands of URLs, multiple sitemaps offer several benefits:

  • Easier debugging and management
  • More efficient search engine crawling
  • Better organization of content types

Enabling Multiple Sitemaps

You can enable multiple sitemaps using the sitemaps option in two ways:

  1. Manual Chunking (object): Best for sites with clear content types (pages, posts, etc.) or fewer than 1000 URLs
  2. Automatic Chunking (true): Best for sites with more than 1000 URLs without clear content types
export default defineNuxtConfig({
  sitemap: {
    // manually chunk into multiple sitemaps
    sitemaps: {
      posts: {
        include: [
          '/blog/**',
        ],
        // example: give blog posts slightly higher priority (this is optional)
        defaults: { priority: 0.7 },
      },
      pages: {
        exclude: [
          '/blog/**',
        ]
      },
    },
  },
})

Customizing sitemap URLs. By default, all multi-sitemaps are served under the /__sitemap__/ prefix. You can customize this behavior to create cleaner URLs:

nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemapsPathPrefix: '/', // or false
    sitemaps: {
      // will be available at /sitemap-foo.xml
      'sitemap-foo': {
        // ...
      }
    }
  }
})

Manual Chunking

Manual chunking gives you complete control over how your URLs are distributed across sitemaps. This approach is ideal when you have distinct content types or specific organizational needs.

Setting Default Values

You can provide default values for URLs within each sitemap using the defaults option:

nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      posts: {
        // posts low priority
        defaults: { priority: 0.7 },
      },
    },
  },
})

Extending App Sources

When you already have all URLs in your single sitemap but want to split them into separate sitemaps, you can extend existing app sources and apply filters.

Available options:

  • includeAppSources: Include URLs from automatic app sources
  • include: Array of glob patterns to include
  • exclude: Array of glob patterns to exclude
nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      pages: {
        // extend the nuxt:pages app source
        includeAppSources: true,
        // filter the URLs to only include pages
        exclude: ['/blog/**'],
      },
      posts: {
        // extend the nuxt:pages app source
        includeAppSources: true,
        // filter the URLs to only include pages
        include: ['/blog/**'],
      },
    },
  },
})

Using the _sitemap key. When using global sources and need to direct specific URLs to particular sitemaps, use the _sitemap key:

export default defineNuxtConfig({
  sitemap: {
    sources: [
      '/api/sitemap-urls'
    ],
    sitemaps: {
      pages: {
        includeAppSources: true,
        exclude: ['/**']
        // ...
      },
    },
  },
})

Managing Custom Sources

For sitemaps that need to fetch URLs from endpoints, you have two options:

  • urls: Static URLs to include in the sitemap (avoid for large URL sets)
  • sources: Endpoints to fetch dynamic URLs from (JSON or XML)
nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      posts: {
        urls() {
          // resolved once at build time; use `sources` for URLs that change at runtime
          return ['/foo', '/bar']
        },
        sources: [
          '/api/sitemap-urls'
        ]
      },
    },
  },
})

Chunking Large Sources

When you have sources that return a large number of URLs, you can enable chunking to split them into multiple XML files:

nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      posts: {
        sources: ['/api/posts'], // returns 10,000 posts
        chunks: true, // Enable chunking with default size (1000)
      },
      products: {
        sources: ['/api/products'], // returns 50,000 products
        chunks: 5000, // Chunk into files with 5000 URLs each
      },
      articles: {
        sources: ['/api/articles'],
        chunks: true,
        chunkSize: 2000, // Alternative way to specify chunk size
      }
    }
  },
})

This will generate:

  • /sitemap_index.xml - Lists all sitemaps including chunks
  • /posts-0.xml - First 1000 posts
  • /posts-1.xml - Next 1000 posts
  • /products-0.xml - First 5000 products
  • /products-1.xml - Next 5000 products
  • etc.

Linking External Sitemaps

Use the special index key to add external sitemaps to your sitemap index:

nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    sitemaps: {
      // generated sitemaps
      posts: {
        // ...
      },
      pages: {
        // ...
      },
      // extending the index sitemap with an external sitemap
      index: [
        { sitemap: 'https://www.google.com/sitemap-pages.xml' }
      ]
    }
  }
})

Automatic Chunking

Automatic chunking divides your sitemap into multiple files based on URL count. This feature:

  • Uses numbered naming convention (0.xml, 1.xml, etc.)
  • Chunks based on defaultSitemapsChunkSize (default: 1000 URLs per sitemap)
  • Should be avoided for sites with fewer than 1000 URLs
nuxt.config.ts
export default defineNuxtConfig({
  sitemap: {
    // automatically chunk into multiple sitemaps
    sitemaps: true,
    // optionally customize chunk size
    defaultSitemapsChunkSize: 2000 // default: 1000
  },
})

Runtime Registration

Sitemaps in nuxt.config are fixed at build time. If your data decides how many you need, register them at runtime instead. A catalog that grows while the server runs is the typical case.

Register sitemaps with the sitemap:sitemaps-resolved hook:

server/plugins/sitemap.ts
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('sitemap:sitemaps-resolved', async ({ sitemaps }) => {
    for (let chunk = 0; chunk < gameChunkCount(); chunk++) {
      sitemaps[`games-${chunk}`] = {
        sitemapName: `games-${chunk}`,
        sources: [`/api/__sitemap__/games?chunk=${chunk}`],
      }
    }
  })
})

See Sitemap Chunking: When built-in chunking isn't enough for chunking strategies, removal, and caching behavior.

Was this page helpful?