Hexo博客Next主题添加相关文章推荐功能
使用Hexo-Related-Posts插件添加相关文章推荐。Hexo-Related-Popular-Posts插件
Hexo-Related-Posts插件
安装插件
于博客站点根目录打开Git Bash,运行下面的命令:
1 | npm install hexo-related-posts --save |
主题配置
Next主题的配置文件_config.next.yml
1 | related_posts: |
修改样式
打开文件hexo\node_modules\hexo-theme-next\layout\_partials\post\post-related.njk
1 | <div class="links-of-blogroll-title"> |
在侧边栏插入
打开文件hexo\node_modules\hexo-theme-next\layout\_macro\sidebar.njk
,插入下面的语句:
1 | {%- if theme.related_posts.enable %} |
插入到文章底部
打开文件hexo\node_modules\hexo-theme-next\layout\_macro\post.njk
,插入下面的语句:
1 | {%- if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %} |
[弃置]Hexo-Related-Popular-Posts不好看
通过Hexo-Related-Popular-Posts插件实现在文章下面显示相关文章推荐。
安装插件
https://github.com/tea3/hexo-related-popular-posts
1 | npm install hexo-related-popular-posts --save |
主题配置
Next主题的配置文件_config.next.yml
1 | related_posts: |
使用
将popular_posts( {} , post )
插入到文章模板中
1 | {{popular_posts( {} , post )}} |
参考
Hexo + NexT 深度个性化配置 (2020.1 更新) | UPWNothing's Playground