Guide
This plugin will automatically generate a Sitemap for your site. To let this plugin work, you need to pass the deployed domain name to the hostname
option of the plugin.
The plugin will automatically generate the last update time of the page based on the Git timestamp of the page, and will also declare the alternative links of the page in other languages according to the locales config.
# Control Sitemap Link
By default, all site links except 404 page will be added to the Sitemap.
To add other pages to the Sitemap outside of the VuePress project page, please turn them into an array and pass to the extraUrls
plugin option.
If you don’t want certain pages to appear in the sitemap, you can turn them into an array and pass them to the excludeUrls
plugin option, or set sitemap.exclude
to true
in the frontmatter of the corresponding page.
# Output Location
You can also control the output link through the sitemapFilename
option of the plugin, the link is relative to doutput directory. By default the plugin will use sitemap.xml
.
# Change Frequency
The default update cycle of the page is daily
(every day). To modify the entire page cycle, please set changefreq
in the plugin options. You can also set sitemap.changefreq
in the frontmatter of the page. Note that page has a higher priority.
The legal frequencies are:
"always"
"hourly"
"daily"
"weekly"
"monthly"
"yearly"
"never"
# Priority
You can set priority
in the plugin to provide a default value. At the same time you can set the priority for each page through sitemap.priority
in fontmatter. Acceptable values are floating point numbers from 0
to 1
.
# Modify Time
You can use option modifyTimeGetter
to return a time in ISO string format, which is generated by the Git plugin by default.
The following is an example based on the last modification time of a file.
// Based on file last modified time
({
modifyTimeGetter: (page) =>
fs.statSync(app.dir.source(page.filePathRelative)).mtime.toISOString();
})
2
3
4
5
# Sitemap Intro
Sitemaps provide SEO (Search Engine Optimization):
- Provide search engine spiders with links of the entire site;
- Provide some links for search engine spiders to dynamic pages or pages that are difficult to reach by other methods;
- If a visitor attempts to access a URL that does not exist within the site’s domain, the visitor will be directed to a "file not found" error page, and the sitemap can be used as a navigation page.
A sitemap enhances SEO by making all pages findable.
Most search engines only follow a limited number of links within a page, so when the site is very large, a sitemap becomes essential to make everything on the site accessible to search engines and visitors.
Sitemaps is a protocol for site administrators to publish pages that can be crawled on a site to search engine spiders. The content of sitemap files must follow the definition in XML format. Each URL can contain the update period and last update time, the priority of the URL across the site. This allows search engines to crawl site content better and more efficiently.
Together with robots.txt
Sitemap is basically used by search engines, when using this plugin, you’d better ensure that you have a valid robot.txt
in the .vuepress/public
directory to allow search engines spiders to visit your site. A simplest robots.txt is as follows (allow all search engines to access all paths)
User-agent: *
Allow: /
2
3