Hexo Next主题添加搜索功能

hexoNexT主题添加搜索非常简单,而且效果很好,需要用到第三方插件hexo-generator-searchdb

安装hexo-generator-searchdb

1
npm install hexo-generator-searchdb

修改站点配置文件_config.yml

_config.yml中添加下面内容

1
2
3
4
5
6
search:
path: search.xml
field: post
content: true
format: html

修改NexT配置文件_config.next.yml

搜索并修改成如下样式:

1
2
3
4
5
6
7
8
9
10
# Local search
# Dependencies: https://github.com/next-theme/hexo-generator-searchdb
local_search:
enable: true
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
# Preload the search data when the page loads.
preload: false