Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/docusaurus/llms.txt
Use this file to discover all available pages before exploring further.
@docusaurus/plugin-sitemap generates a sitemap.xml file at build time so that search engine crawlers can discover and index your site’s pages. The plugin respects the noIndex and trailingSlash settings in docusaurus.config.js and is included in @docusaurus/preset-classic with sensible defaults.
Installation
npm2yarn
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
changefreq | string | null | 'weekly' | The <changefreq> value written into every sitemap entry. Any value from the sitemap protocol is accepted (always, hourly, daily, weekly, monthly, yearly, never). Set null to omit the tag. |
priority | number | null | 0.5 | The <priority> value written into every sitemap entry (0.0–1.0). Set null to omit the tag. |
lastmod | 'date' | 'datetime' | null | null | Controls the <lastmod> tag format. 'date' outputs YYYY-MM-DD; 'datetime' outputs a full ISO 8601 timestamp. null disables the tag. |
ignorePatterns | string[] | [] | Glob patterns for route paths to exclude from the sitemap. You may need to include the base URL in patterns. |
filename | string | 'sitemap.xml' | Output file name, relative to the build output directory. Useful when running multiple plugin instances to avoid filename conflicts. |
createSitemapItems | CreateSitemapItemsFn | undefined | undefined | Optional function to transform or filter sitemap entries after they are generated. |
Type definitions
CreateSitemapItemsFn
Site config integration
The plugin also reads two global site config options:
noIndex: true— the entire sitemap is suppressed; nositemap.xmlis generated.trailingSlash— controls whether URLs in the sitemap end with a trailing slash.
About lastmod
The lastmod option only writes a <lastmod> tag for routes where a plugin has attached sourceFilePath or lastUpdatedAt metadata via addRoute. All official content plugins (plugin-content-docs, plugin-content-blog, plugin-content-pages) provide this metadata for Markdown and MDX files automatically. Custom or third-party plugins may not, in which case <lastmod> will not appear for those routes.
Example configuration
- Preset options (recommended)
- Standalone plugin
docusaurus.config.js
Filtering sitemap items
UsecreateSitemapItems to exclude specific URLs or modify properties per-entry. The function receives the full list of generated items and must return a (possibly modified) array:
docusaurus.config.js
Multiple sitemap instances
Run two instances of the plugin to produce separate sitemaps for distinct content areas:docusaurus.config.js
/sitemap.xml (or the path you configured with filename).