Hexo 添加搜索功能
博客搭建相关,如何向hexo添加简单的本地搜索功能?
安装
hexo-generator-searchdb
1.在站点的根目录下执行以下命令: 2.编辑站点配置文件 1
npm install hexo-generator-searchdb --save
_config.yml
,新增以下内容到任意位置: 3.编辑主题配置文件 1
2
3
4
5search:
path: search.xml
field: post
format: html
limit: 10000_config.yml
,启用本地搜索功能: 4.然后 重新生成 查看: 1
2
3
4
5
6
7local_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 5.这样,搜索功能就添加上了。1
2
3
4
5$ hexo clean
$ hexo g
$ hexo s
INFO Start processing
INFO Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
6.参考连接
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!