You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VitePress comes with out-of-the-box support for generating a `sitemap.xml` file for your site. To enable it, add the following to your `.vitepress/config.js`:
4
+
5
+
```ts
6
+
import { defineConfig } from'vitepress'
7
+
8
+
exportdefaultdefineConfig({
9
+
sitemap: {
10
+
hostname: 'https://example.com'
11
+
}
12
+
})
13
+
```
14
+
15
+
To have `<lastmod>` tags in your `sitemap.xml`, you can enable the [`lastUpdated`](../reference/default-theme-last-updated) option.
16
+
17
+
## Options
18
+
19
+
Sitemap support is powered by the [`sitemap`](https://www.npmjs.com/package/sitemap) module. You can pass any options supported by it to the `sitemap` option in your config file. These will be passed directly to the `SitemapStream` constructor. Refer to the [`sitemap` documentation](https://www.npmjs.com/package/sitemap#options-you-can-pass) for more details. Example:
20
+
21
+
```ts
22
+
import { defineConfig } from'vitepress'
23
+
24
+
exportdefaultdefineConfig({
25
+
sitemap: {
26
+
hostname: 'https://example.com',
27
+
lastmodDateOnly: false
28
+
}
29
+
})
30
+
```
31
+
32
+
## `transformItems` Hook
33
+
34
+
You can use the `sitemap.transformItems` hook to modify the sitemap items before they are written to the `sitemap.xml` file. This hook is called with an array of sitemap items and expects an array of sitemap items to be returned. Example:
0 commit comments