本地搜索

hexo实现站内搜索,实则上是使用了hexo-generator-search插件

安装

根据它的文档去做相应配置。注意格式只支持 xml。

1
npm install hexo-generator-search --save

配置

修改主题配置文件_config.butterfly.yml

1
2
3
4
5
local_search:
enable: true
labels:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" # if there are no result

Algolia

你需要安装 hexo-algoliahexo-algoliasearch. 根据它们的説明文档去做相应的配置。

安装

1
npm install hexo-algolia --save

配置

修改主题配置文件_config.butterfly.yml

1
2
3
4
5
6
7
8
algolia_search:
enable: true
hits:
per_page: 6
labels:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
hits_stats: "${hits} results found in ${time} ms"