本文最后更新于:2024年1月14日 晚上

Next 7.7 将RSS按钮的代码删掉了,按照以往添加RSS的方法设置后可以生成xml文件,但没有按钮。本文介绍在Next 7.7 添加带按钮的RSS方法。

添加RSS

安装插件 hexo-generator-feed

在hexo 目录运行命令:

1
npm install hexo-generator-feed --save

配置站点配置文件

在站点配置文件添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14

plugins: hexo-generate-feed

# rss配置
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date

配置Next主题配置文件

主题配置文件默认没有rss字段,需要自己手动添加

1
2
3
4
# Set rss to false to disable feed link.
# Leave rss as blank to use site's feed link, and install hexo-generator-feed: `npm install hexo-generator-feed --save`.
# Set rss to specific value if you have burned your feed already.
rss: /atom.xml

测试

此时运行hexo g已经可以看到

1
INFO  Generated: atom.xml

事实上已经配置成功

但是侧边栏没有RSS按钮

在侧边栏添加RSS按钮

在Hexo/themes/next/layout/_partials/sidebar文件夹,打开site-overview.swig文件

- if theme.site_state 前加入代码:

1
2
3
4
5
6
7
8
9
{% if theme.rss %}
<div class="feed-link motion-element">
<a href="{{ url_for(theme.rss) }}" rel="alternate">
<i class="fa fa-rss"></i>
RSS
</a>
</div>
{% endif %}

执行hexo g && hexo s 即可查看效果



文章链接:
https://www.zywvvd.com/notes/hexo/theme/next/14-add-rss/next-add-rss/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

Next -14- 为Hexo Next7.7.1 添加RSS (带按钮)
https://www.zywvvd.com/notes/hexo/theme/next/14-add-rss/next-add-rss/
作者
Yiwei Zhang
发布于
2020年3月20日
许可协议