Disclaimer
This document was translated by me 机翻 from the official documentation at hexo-generator-feed, and is kept here for reference only.
hexo-generator-feed official documentation: https://github.com/hexojs/hexo-generator-feed
hexo-generator-feeds
Generates Atom 1.0 or RSS 2.0 feeds for your blog.
Installation
$ npm install hexo-generator-feed --saveSupported Hexo versions:
- Hexo 4+: 2.x
- Hexo 3: 1.x
- Hexo 2: 0.x
Usage
In the front-matter section of a post, you can optionally add description, intro, or excerpt settings to write a summary for the post. Otherwise, the summary defaults to the excerpt or the first 140 characters of the post.
Configuration
You can configure this plugin in Hexo’s _config.yml.
feed:
enable: true
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: " "
order_by: -date
icon: icon.png
autodiscovery: true
template:enable - Enable or disable this plugin. Enabled by default.
type - Feed type.
atomorrss2. Specify['atom', 'rss2']to output both types. (Default:atom)- Example:
feed: # Generate atom feed type: atom # Generate both atom and rss2 feeds type: - atom - rss2 path: - atom.xml - rss2.xmlpath - Feed path. When two types are specified, the paths must follow the order of the type values. (Default: atom.xml/rss2.xml)
limit - Maximum number of posts in the feed (use
0orfalseto show all posts)hub - URL of the PubSubHubbub hub (leave it empty if you don’t use it)
content - (Optional) Set to
trueto include the full content of the post in the feed.content_limit - (Optional) Default number of characters of post content in the summary. Only used when content is set to
falseand no custom post description exists.content_limit_delim - (Optional) If content_limit is used to shorten post content, the cut is made only at the last occurrence of this delimiter before the character limit is reached. Not used by default.
order_by - Order of the feed. (Default: -date)
icon - (Optional) Custom feed icon. Defaults to the email avatar specified in the main config.
autodiscovery - Adds feed 自动发现. (Default:
true)- Many themes already provide this feature, so if you want to disable it, you may also need to adjust the theme’s configuration.
template - Custom template path. This file will be used to generate the feed xml file; see the default templates: atom.xml and rss2.xml.
- You can specify just one custom template even if this plugin is configured to output both feed types.
# (Optional) Exclude custom template from being copied into public/ folder # Alternatively, you could also prepend an underscore to its filename, e.g. _custom.xml # https://hexo.io/docs/configuration#Include-Exclude-Files-or-Folders exclude: - "custom.xml" feed: type: - atom - rss2 template: - ./source/custom.xml # atom will be generated using custom.xml # rss2 will be generated using the default template instead
