Skip to main content

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.
This plugin is always inactive in development. It only runs during a production build (docusaurus build) because it works on the final build output.

Installation

npm2yarn
npm install --save @docusaurus/plugin-sitemap
If you use @docusaurus/preset-classic, configure this plugin through the sitemap preset key instead of adding it to the plugins array.

Configuration options

OptionTypeDefaultDescription
changefreqstring | 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.
prioritynumber | null0.5The <priority> value written into every sitemap entry (0.0–1.0). Set null to omit the tag.
lastmod'date' | 'datetime' | nullnullControls the <lastmod> tag format. 'date' outputs YYYY-MM-DD; 'datetime' outputs a full ISO 8601 timestamp. null disables the tag.
ignorePatternsstring[][]Glob patterns for route paths to exclude from the sitemap. You may need to include the base URL in patterns.
filenamestring'sitemap.xml'Output file name, relative to the build output directory. Useful when running multiple plugin instances to avoid filename conflicts.
createSitemapItemsCreateSitemapItemsFn | undefinedundefinedOptional function to transform or filter sitemap entries after they are generated.

Type definitions

CreateSitemapItemsFn

type CreateSitemapItemsFn = (params: {
  siteConfig: DocusaurusConfig;
  routes: RouteConfig[];
  defaultCreateSitemapItems: CreateSitemapItemsFn;
}) => Promise<SitemapItem[]>;

Site config integration

The plugin also reads two global site config options:
  • noIndex: true — the entire sitemap is suppressed; no sitemap.xml is 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

Filtering sitemap items

Use createSitemapItems 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
export default {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        sitemap: {
          createSitemapItems: async (params) => {
            const {defaultCreateSitemapItems, ...rest} = params;
            const items = await defaultCreateSitemapItems(rest);
            // Exclude paginated list pages from the sitemap
            return items.filter((item) => !item.url.includes('/page/'));
          },
        },
      },
    ],
  ],
};

Multiple sitemap instances

Run two instances of the plugin to produce separate sitemaps for distinct content areas:
docusaurus.config.js
export default {
  plugins: [
    [
      '@docusaurus/plugin-sitemap',
      {
        id: 'docs-sitemap',
        ignorePatterns: ['/blog/**'],
        filename: 'sitemap-docs.xml',
      },
    ],
    [
      '@docusaurus/plugin-sitemap',
      {
        id: 'blog-sitemap',
        ignorePatterns: ['/docs/**'],
        filename: 'sitemap-blog.xml',
      },
    ],
  ],
};
After building, find your sitemap at /sitemap.xml (or the path you configured with filename).

Build docs developers (and LLMs) love