hexo搭建的博客增加搜索功能

具体操作

1.安装搜索:在Hexo的根目录下,打开命令可执行窗口,执行如下命令:

1
npm install hexo-generator-searchdb --save

2.blog目录下的全局配置文件_config.yml,新增如下内容:

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

3.hexo主题配置文件(\themes_config.yml),修改local_search的enable为true:

1
2
3
4
5
6
7
8
9
# Local search
# Dependencies: https://github.com/flashlab/hexo-generator-search
local_search:
enable: true
# if auto, trigger search by changing input
# if manual, trigger search by pressing enter key or search button
trigger: auto
# show top n results per article, show all results by setting to -1
top_n_per_article: 1