📦 plugin-sitemap
This plugin creates sitemaps for your site so that search engine crawlers can crawl your site more accurately.
production only
This plugin is always inactive in development and only active in production because it works on the build output.
Installation
- npm
- Yarn
- pnpm
npm install --save @docusaurus/plugin-sitemap
yarn add @docusaurus/plugin-sitemap
pnpm add @docusaurus/plugin-sitemap
提示
If you use the preset @docusaurus/preset-classic
, you don't need to install this plugin as a dependency.
You can configure this plugin through the preset options.
Configuration
Accepted fields:
Name | Type | Default | Description |
---|---|---|---|
changefreq | string | 'weekly' | See sitemap docs |
priority | number | 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. |
信息
This plugin also respects some site config:
noIndex
: results in no sitemap generatedtrailingSlash
: determines if the URLs in the sitemap have trailing slashes
Example configuration
You can configure this plugin through preset options or plugin options.
提示
Most Docusaurus users configure this plugin through the preset options.
- 预设选项
- 插件选项
如果使用预设,请通过预设选项配置此插件:
docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
sitemap: {
changefreq: 'weekly',
priority: 0.5,
ignorePatterns: ['/tags/**'],
filename: 'sitemap.xml',
},
},
],
],
};
如果您使用的是独立插件,请直接向插件提供选项:
docusaurus.config.js
module.exports = {
plugins: [
[
'@docusaurus/plugin-sitemap',
{
changefreq: 'weekly',
priority: 0.5,
ignorePatterns: ['/tags/**'],
filename: 'sitemap.xml',
},
],
],
};
You can find your sitemap at /sitemap.xml
.