2022-02-25 10:00:11 -05:00
---
sidebar_position: 10
2022-07-08 12:34:05 -04:00
slug: /api/plugins/@docusaurus/plugin-sitemap
2022-02-25 10:00:11 -05:00
---
2022-07-08 12:34:05 -04:00
# 📦 plugin-sitemap
2022-02-25 10:00:11 -05:00
import APITable from '@site/src/components/APITable';
This plugin creates sitemaps for your site so that search engine crawlers can crawl your site more accurately.
2023-09-15 04:48:21 -04:00
:::warning production only
2022-02-25 10:00:11 -05:00
This plugin is always inactive in development and **only active in production** because it works on the build output.
:::
## Installation {#installation}
```bash npm2yarn
npm install --save @docusaurus/plugin-sitemap
```
:::tip
If you use the preset `@docusaurus/preset-classic`, you don't need to install this plugin as a dependency.
2024-01-12 10:09:45 -05:00
You can configure this plugin through the [preset options](../../using-plugins.mdx#docusauruspreset-classic).
2022-02-25 10:00:11 -05:00
:::
## Configuration {#configuration}
Accepted fields:
2022-07-08 12:34:05 -04:00
```mdx-code-block
2022-02-25 10:00:11 -05:00
<APITable>
2022-07-08 12:34:05 -04:00
```
2022-02-25 10:00:11 -05:00
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `changefreq` | `string` | `'weekly'` | See [sitemap docs](https://www.sitemaps.org/protocol.html#xmlTagDefinitions) |
| `priority` | `number` | `0.5` | See [sitemap docs](https://www.sitemaps.org/protocol.html#xmlTagDefinitions) |
2022-05-05 14:26:48 -04:00
| `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. |
2022-07-08 12:34:05 -04:00
| `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. |
2022-02-25 10:00:11 -05:00
2022-07-08 12:34:05 -04:00
```mdx-code-block
2022-02-25 10:00:11 -05:00
</APITable>
2022-07-08 12:34:05 -04:00
```
2022-02-25 10:00:11 -05:00
:::info
This plugin also respects some site config:
2022-12-30 09:08:28 -05:00
- [`noIndex`](../docusaurus.config.js.mdx#noIndex): results in no sitemap generated
- [`trailingSlash`](../docusaurus.config.js.mdx#trailingSlash): determines if the URLs in the sitemap have trailing slashes
2022-02-25 10:00:11 -05:00
:::
### Example configuration {#ex-config}
You can configure this plugin through preset options or plugin options.
:::tip
Most Docusaurus users configure this plugin through the preset options.
:::
```js config-tabs
// Preset Options: sitemap
// Plugin Options: @docusaurus/plugin-sitemap
const config = {
changefreq: 'weekly',
priority: 0.5,
2022-05-05 14:26:48 -04:00
ignorePatterns: ['/tags/**'],
2022-07-08 12:34:05 -04:00
filename: 'sitemap.xml',
2022-02-25 10:00:11 -05:00
};
```
You can find your sitemap at `/sitemap.xml`.