π¦ plugin-sitemap
This plugin creates sitemaps for your site so that search engine crawlers can crawl your site more accurately.
Installation
Section titled βInstallationβnpm install --save @docusaurus/plugin-sitemapConfiguration
Section titled βConfigurationβAccepted fields:
<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. |
</APITable>CreateSitemapItemsFn
Section titled βCreateSitemapItemsFnβtype CreateSitemapItemsFn = (params: {
siteConfig: DocusaurusConfig;
routes: RouteConfig[];
defaultCreateSitemapItems: CreateSitemapItemsFn;
}) => Promise<SitemapItem[]>;Example configuration
Section titled βExample configurationβYou can configure this plugin through preset options or plugin options.
// 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.