hexo部署algolia搜索

注册algolia

algolia官网

可以使用github 和谷歌账号 直接登录(直接跳过新手引导)

新建index

新建index

获取key放到站点配置文件里面(不是主题的配置文件)
1
2
3
4
5
algolia:
applicationID: 'applicationID'
apiKey: 'apiKey-seach-only'
indexName: 'indexName'
chunkSize: 5000

所有的key都在如下界面获取
keys

安装hexo-algolia扩展
1
npm install --save hexo-algolia

注意 theam 5.1版本以后要使用如下命令

1
npm install hexo-algolia@0.2.0
更新index(在项目目录下)
1
hexo algolia
项目集成

更改主题配置文件

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

enable 改为 true 即可,根据需要你可以调整 labels 中的文本。