hexo博客添加搜索功能
安装插件
在自己博客根目录下(我的目录:D:\workspace\hexo),执行如下命令
cnpm install hexo-generator-searchdb --save
修改站点配置文件
修改根目录下的_config.yml(我的目录:D:\workspace\hexo_config.yml),在最底部添加如下配置
search:
path: search.xml
field: post
format: html
limit: 10000
修改主题配置文件
修改主体下的themes\next_config.yml配置文件(我的目录:D:\workspace\hexo\themes\next_config.yml),搜索local_search,修改enable为true
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
预览效果
开启本地server
hexo clean
hexo g
hexo s
访问:http://localhost:4000/ ,即可看到想要的搜索功能了