VuePress EcosystemVuePress Ecosystem
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • SEO
  • Sitemap

sitemap

@vuepress/plugin-sitemap

Generate a sitemap for your site.

Usage

npm i -D @vuepress/plugin-sitemap@next
.vuepress/config.ts
import { sitemapPlugin } from '@vuepress/plugin-sitemap'

export default {
  plugins: [
    sitemapPlugin({
      hostname: 'https://example.com',
    }),
  ],
}

The hostname option is required, as the sitemap links are generated from it.

The plugin uses the last update time from @vuepress/plugin-git, and declares the alternative links of every page in other languages according to the locale config.

Link Control

By default, every link of the site is included in the sitemap, except the 404 page.

  • Use the extraUrls option to include pages that are not generated by VuePress, typically files in the public directory.
  • Use the excludePaths option, or set the sitemap frontmatter to false, to exclude a page.

Update Frequency

The default update frequency of a page is daily, which can be changed with the changefreq option, or per page with the sitemap.changefreq frontmatter.

The legal frequencies are always, hourly, daily, weekly, monthly, yearly and never.

Modify Time

The modifyTimeGetter option returns the last update time of a page in the ISO string format, which comes from @vuepress/plugin-git by default.

// Based on the last modified time of the file
;({
  modifyTimeGetter: (page, app) =>
    fs.statSync(app.dir.source(page.filePathRelative)).mtime.toISOString(),
})

robots.txt

The sitemap is read by search engines, so you should provide a valid robots.txt in the .vuepress/public directory to allow the crawlers. The simplest one is:

User-agent: *

Allow: /

Options

hostnameRequiredstring

The hostname where the site is deployed.

extraUrlsstring[]

The extra links to be included, e.g. ['/about.html', '/api/'].

excludePathsstring[]
Default['/404.html']

The page paths to be excluded, starting with an absolute path.

sitemapFilenamestring
Default'sitemap.xml'

The output filename of the sitemap, relative to the output directory.

sitemapXSLFilenamestring
Default'sitemap.xsl'

The output filename of the XSL file, relative to the output directory.

sitemapXSLTemplatestring

The content of the XSL template, which defaults to the built-in sitemap.xsl.

changefreq'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'
Default'daily'

The default update frequency of a page. See also: Update Frequency.

modifyTimeGetter(page: Page, app: App) => string

The getter of the last update time of a page. See also: Modify Time.

xmlNameSpace{ news: boolean; video: boolean; xhtml: boolean; image: boolean; custom?: string[] }

The XML namespaces to enable, all of them are enabled by default.

devServerboolean

Whether to generate the sitemap in the development server.

devHostnamestring
Default'http://localhost:${port}'

The hostname used in the development server.

Frontmatter

sitemapSitemapFrontmatterOption | false

Whether to include the page in the sitemap, or the sitemap config of the page.

sitemap.changefreq'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'
Default'daily'

The update frequency of the page.

sitemap.prioritynumber

The priority of the page, from 0 to 1.

sitemap.imgSitemapImageOption[]

The images of the page.

sitemap.videoSitemapVideoOption[]

The videos of the page.

sitemap.newsSitemapNewsOption[]

The news of the page.

Related

  • Sitemaps protocol
Edit this page on GitHub
Last Updated: 9/28/26, 4:40 AM
Contributors: Mister-Hope
Prev
SEO