Config
enabled
- Type:
boolean - Default:
true
Whether to generate the sitemap.
sortEntries
- Type:
boolean - Default:
true
Whether the sitemap entries should be sorted or be shown in the order they were added.
When enabled the entries will be sorted by the loc, they will be sorted by the path segment
count and then alphabetically using String.localeCompare to ensure numbers are sorted correctly.
sources
- Type:
SitemapSource[] - Default:
[]
The sources to use for the sitemap. See Data Sources and Dynamic URL Endpoint for details.
excludeAppSources
- Type:
boolean|AppSourceId[] - Default:
false
Whether to exclude app sources from the sitemap.
appendSitemaps
- Type:
(string | { sitemap: string, lastmod?: Date })[] - Default:
false
Sitemaps to append to the sitemap index.
This will only do anything when using multiple sitemaps.
autoLastmod
- Type:
boolean - Default:
false
Whether to automatically detect the lastmod date for each URL.
If the lastmod date can't be inferred from a route page file it will use the current Date.
sitemaps
- Type:
SitemapConfig[] | boolean - Default:
false
Whether to generate multiple sitemaps.
Each sitemap can have the following options:
SitemapConfig
sources
- Type:
SitemapSource[] - Default:
[]
Data sources for this specific sitemap.
chunks
- Type:
boolean | number - Default:
undefined
Enable chunking for sitemap sources. This splits large collections of URLs from sources into multiple smaller sitemap files to stay within search engine limits.
- Set to
trueto enable chunking with the default chunk size (fromdefaultSitemapsChunkSizeor 1000) - Set to a positive number to use that as the chunk size (e.g.,
5000for 5000 URLs per chunk) - Set to
falseor leave undefined to disable chunking
Note: Chunking only applies to URLs from sources. Direct URLs in the urls property are not chunked.
export default defineNuxtConfig({
sitemap: {
sitemaps: {
products: {
sources: ['/api/products'],
chunks: 5000 // Split into files with 5000 URLs each
}
}
}
})
chunkSize
- Type:
number - Default:
undefined
Explicitly set the chunk size for this sitemap. Takes precedence over the chunks property when both are specified.
export default defineNuxtConfig({
sitemap: {
sitemaps: {
posts: {
sources: ['/api/posts'],
chunks: true, // Enable chunking
chunkSize: 2500 // Use 2500 URLs per chunk
}
}
}
})
See the Chunking Sources guide for more details.
urls
- Type:
string[] | (() => string[] | Promise<string[]>) - Default:
[]
Static URLs to include in this sitemap.
include
- Type:
(string | RegExp)[] - Default:
undefined
Filter URLs to include in this sitemap.
exclude
- Type:
(string | RegExp)[] - Default:
undefined
Filter URLs to exclude from this sitemap.
defaults
- Type:
SitemapItemDefaults - Default:
{}
Default values for all URLs in this sitemap.
includeAppSources
- Type:
boolean - Default:
false
Whether to include automatic app sources in this sitemap.
See Multi Sitemaps for details.
defaultSitemapsChunkSize
- Type:
number | false - Default:
1000
The default chunk size when chunking is enabled for multi-sitemaps. This value is used when:
- A sitemap has
chunks: true(without specifying a number) - No
chunkSizeis explicitly set for the sitemap
Set to false to disable chunking by default for all sitemaps.
export default defineNuxtConfig({
sitemap: {
defaultSitemapsChunkSize: 5000,
sitemaps: {
// These will use 5000 as chunk size
posts: {
sources: ['/api/posts'],
chunks: true
},
// This overrides the default
products: {
sources: ['/api/products'],
chunks: 10000
}
}
}
})
defaults
- Type:
object - Default:
{}
Default values for the sitemap.xml entries. See sitemaps.org for all available options.
urls
- Type:
() => MaybePromise<SitemapEntry[]> | MaybePromise<SitemapEntry[]> - Default:
[]
Provide custom URLs to be included in the sitemap.xml.
include
- Type:
(string | RegExp)[] - Default:
['/**']
Filter routes that match the given rules. See the Filtering URLs guide for details.
export default defineNuxtConfig({
sitemap: {
include: [
'/my-hidden-url'
]
}
})
exclude
- Type:
(string | RegExp)[] - Default:
undefined
Filter routes that match the given rules. See the Filtering URLs guide for details.
export default defineNuxtConfig({
sitemap: {
exclude: [
'/my-secret-section/**'
]
}
})
xsl
- Type:
string | false - Default:
/__sitemap__/style.xsl
The path to the XSL stylesheet for the sitemap.xml. Set to false to disable.
discoverImages
- Type:
boolean - Default:
true
Whether to discover images from routes when prerendering.
discoverVideos
- Type:
boolean - Default:
true
Whether to discover videos from routes when prerendering.
autoI18n
- Type:
undefined | boolean | { locales: NormalisedLocales; defaultLocale: string; strategy: 'prefix' | 'prefix_except_default' | 'prefix_and_default' } - Default:
undefined
Automatically add alternative language prefixes for each entry with the given prefixes. Set to false to disable.
When using the @nuxtjs/i18n module, this will automatically be set to the configured locales when left undefined.
sitemapName
- Type:
string - Default:
sitemap.xml
Modify the name of the root sitemap.
Note: This only works when you're not using the multiple sitemaps option.
strictNuxtContentPaths
- Type:
boolean - Default:
false
Whether the paths within nuxt/content match their real paths. This is useful when you're using the nuxt/content module
without documentDriven mode.
cacheMaxAgeSeconds
- Type:
number - Default:
60 * 10
The time in seconds to cache the sitemaps.
sitemapsPathPrefix
- Type:
string | false - Default:
/__sitemap__/
The path prefix for the sitemaps when using multiple sitemaps.
runtimeCacheStorage
- Type:
boolean | (Record<string, any> & { driver: string }) - Default:
true
The storage engine to use for the cache. See Caching for details.
xslColumns
- Type:
({ label: string; width: `${string}%`; select?: string })[] - Default:
[
{ "label": "URL", "width": "50%" },
{ "label": "Images", "width": "25%", "select": "count(image:image)" },
{ "label": "Last Updated", "width": "25%", "select": "concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)),concat(' ', substring(sitemap:lastmod,20,6)))" }
]
The columns to display in the XSL stylesheet.
xslTips
- Type:
boolean - Default:
true
Whether to include tips on how to use the sitemap in the XSL stylesheet.
experimentalWarmUp
- Type:
boolean - Default:
false
Should the sitemaps be warmed up when Nitro starts. This can be useful for large sitemaps.
experimentalCompression
- Type:
boolean - Default:
false
Should the sitemaps be compressed and streamed when the request accepts it.
credits
- Type:
boolean - Default:
true
Whether to include a comment on the sitemaps on how it was generated.
debug
- Type:
boolean - Default:
false
Enable to see debug logs and API endpoint.
The route at /__sitemap__/debug.json will be available in non-production environments.
See the Debugging guide for details.