hexo开启rss订阅

什么是RSS

RSS 的全称有三种说法,RDF Site Summary(资源描述框架站点摘要)、Rich Site Summary(网站内容摘要)和 Really Simple Syndication(简易资讯聚合)

RSS是一个能让你在一个地方订阅各种感兴趣网站的工具

如何在Hexo中使用RSS

安装插件

在Hexo中使用RSS有很多种方式,这里以butterfly主题为例

首先确保你的环境中有node并且安装了Hexo

然后输入

1
npm install hexo-generator-feed --save

配置文件

然后打开hexo根目录下的_config.yml文件,输入一下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
feed:
enable: true
type: atom
path: atom.xml
limit: 20
hub: #这个我没用上,根据官网,空着就行
content: #默认是false,true的话会在rss文件中包含整个文章内容
content_limit: 140 #摘要长度
content_limit_delim: ' ' #没看明白官方的意思,就跟着默认不填了
order_by: -date
icon: icon.png
autodiscovery: true
template:

这里放一下官方的解释

  • path - Feed path. When both types are specified, path must follow the order of type value. (Default: atom.xml/rss2.xml)
  • limit - Maximum number of posts in the feed (Use 0 or false to show all posts)
  • hub - URL of the PubSubHubbub hubs (Leave it empty if you don’t use it)
  • content - (optional) set to ‘true’ to include the contents of the entire post in the feed.
  • content_limit - (optional) Default length of post content used in summary. Only used, if content setting is false and no custom post description present.
  • content_limit_delim - (optional) If content_limit is used to shorten post contents, only cut at the last occurrence of this delimiter before reaching the character limit. Not used by default.
  • order_by - Feed order-by. (Default: -date)
  • icon - (optional) Custom feed icon. Defaults to a gravatar of email specified in the main config.
  • autodiscovery - Add feed autodiscovery. (Default: true)
  • Many themes already offer this feature, so you may also need to adjust the theme’s config if you wish to disable it.
  • template - Custom template path(s). This file will be used to generate feed xml file, see the default templates: atom.xml and rss2.xml.
  • It is possible to specify just one custom template, even when this plugin is configured to output both feed types,

各位可以打开翻译看一下意思

完成以上配置后我们接着打开主题目录下的_config.yaml文件

输入

1
rss: /atom.xml

然后在主题中的social settings中添加如下配置

1
fas fa-rss: {你的域名}/atom.xml

大功告成

这个时候输入

1
hexo g -d

就会自动生成atom.xml文件了,然后打开域名加/atom.xml就是RSS的订阅链接了

预告

关于RSS的订阅方式,敬请期待