[Hexo] Use hexo-generator-sitemap plugin to generate sitemap.xml automatically in Hexo
hexo-generator-sitemap
Hexo is a fast, simple & powerful blog framework. It use plugins to provide features powerful APIs for limitless extensibility. Various plugins are available to support most template engines (EJS, Pug, Nunjucks, and many others). Easily integrate with existing NPM packages (Babel, PostCSS, Less/Sass, etc).
hexo-generator-sitemap
plugin will generate sitemap files for Hexo
pages, posts, categories, tags.
Installation
Use npm
to install hexo-generator-sitemap
package.
1 | npm install hexo-generator-sitemap --save |
Configuration
It will generate sitemap.xml
in the public folder by default after hexo-generator-sitemap
installation.
You can configure this plugin in ./_config.yml.
1 | sitemap: |
The follow is the options:
-
path - Sitemap path. (Default: sitemap.xml)
-
template - Custom template path. This file will be used to generate sitemap.xml. (See default template)
-
rel - Add rel-sitemap to the site’s header. (Default: false)
-
tags - Add site’s tags. (Default: true)
-
categories - Add site’s categories. (Default: true)
Exclude Posts/Pages
Add sitemap: false
to the post/page’s front matter in order to exclude from sitemap.
1 |
|
Finally, you can visit <Your Site Url>/sitemap.xml
in the browser, and check whether the sitemap.xml
works correctly after Hexo restarted or regenerated.
FAQs
no such file or directory, open ‘./sitemap_template.xml’
1 | hexo g |
Check hexo
and hexo-generator-sitemap
version:
1 | hexo 6.0.0 |
Comment template: ./sitemap_template.xml
within ./_config.yml
, and run hexo g
again.
1 | sitemap: |