Skip to main content
Docusaurus

Search documentation

Type to search this documentation.

On this pageOverview

πŸ“¦ plugin-sitemap

This plugin creates sitemaps for your site so that search engine crawlers can crawl your site more accurately.

npm2yarn
npm install --save @docusaurus/plugin-sitemap

Accepted fields:

mdx-code-block
<APITable>
Name Type Default Description
lastmod 'date' | 'datetime' | null null date is YYYY-MM-DD. datetime is a ISO 8601 datetime. null is disabled. See sitemap docs.
changefreq string | null 'weekly' See sitemap docs
priority number | null 0.5 See sitemap docs
ignorePatterns string[] [] A list of glob patterns; matching route paths will be filtered from the sitemap. Note that you may need to include the base URL in here.
filename string sitemap.xml The path to the created sitemap file, relative to the output directory. Useful if you have two plugin instances outputting two files.
createSitemapItems [CreateSitemapItemsFn](#CreateSitemapItemsFn) | undefined undefined An optional function which can be used to transform and / or filter the items in the sitemap.
mdx-code-block
</APITable>
TypeScript
type CreateSitemapItemsFn = (params: {
  siteConfig: DocusaurusConfig;
  routes: RouteConfig[];
  defaultCreateSitemapItems: CreateSitemapItemsFn;
}) => Promise<SitemapItem[]>;

You can configure this plugin through preset options or plugin options.

config-tabs
// Preset Options: sitemap
// Plugin Options: @docusaurus/plugin-sitemap

const config = {
  lastmod: 'date',
  changefreq: 'weekly',
  priority: 0.5,
  ignorePatterns: ['/tags/**'],
  filename: 'sitemap.xml',
  createSitemapItems: async (params) => {
    const {defaultCreateSitemapItems, ...rest} = params;
    const items = await defaultCreateSitemapItems(rest);
    return items.filter((item) => !item.url.includes('/page/'));
  },
};

You can find your sitemap at /sitemap.xml.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu