hexo进阶之添加菜单
分类、标签、搜索
- 工具:hexo + NexT
- 环境:mac(10.13.2)、node.js(9.4.0)、npm(5.6.0)
前言
上一篇已经搭建了最简单的博客,没有常见的菜单:分类、标签、音乐、搜索、RSS订阅、个人,这一篇就是完善这个菜单功能。
添加菜单
修改NexT下的主题配置文件
1 | $ vim theme/next/_config.yml |
编辑页面显示的菜单中文名称
编辑Next目录下的languages/{language}.yml文件,{language}.yml为站点_config.yml中配置的languages: zh-Hans对应
1 | $ vim /theme/next/languages/zh-Hans.yml |
到这里,已经添加了归档、分类等菜单,但是点击是没有效果的。
配置菜单对应内容
分类菜单
1 | ## 创建categories页面 |
标签菜单
1 | ## 创建tags页面 |
注:分类和标签还没有和分类关联起来,需要在每篇文章头部添加categories和tags属性,这样就可以自动关联了,为了后续方便,修改scaffolds/post.md模版即可。
1 | title: hexo+github快速搭建博客 |
搜索菜单
采用Hexo提供的Local Search站内搜索,原理是通过hexo-generator-search插件在本地生成一个search.xml文件,搜索的时候从这个文件中根据关键字检索出相应的链接。
1 | ## 在站点根目录下安装 |
注:由于使用了local search,主题配置文件中就menu属性就不需要添加search了。
参考
- https://theme-next.iissnan.com/getting-started.html NexT开始使用
- https://github.com/iissnan/hexo-theme-next/blob/master/README.cn.md NexT使用文档
- http://cherryblog.site/Hexo-high-level-tutorialcloudmusic,bg-customthemes-statistical.html hexo搭建
本文作者:ttbb
本文地址: http://steven-ji.github.io/blog/2018/03/26/hexo进阶之分类、标签、搜索/
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!