Tranquilpeak Setup algolia search
目录
注册并获取相关帐号信息
到Algolia观望注册一个帐号,然后新建一个index,可以在algolia站点找到Application, Search-Only API Key, Admin API Key。点击ALL API KEYS 找到新建INDEX对应的key,编辑权限,在弹出框中找到ACL选择勾选Add records, Delete records, List indices, Delete index权限,点击update更新。
编辑站点配置文件
编辑hexo根目录下的_config.yml文件,加入下列行:
Algolia setting
algolia:
appId: "**************"
apiKey: "**********"
adminApiKey: "************"
chunkSize: 5000
indexName: "Blog"
fields:
- content:strip:truncate,0,500
- excerpt:strip
- gallery
- permalink
- photos
- slug
- tags
- title
将文件中设置部分打开:
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"
如何使用
每一次添加新的文章到要做一次:
export HEXO_ALGOLIA_INDEXING_KEY=你的API Key
hexo algolia
上面相当于建立搜索index上传到网上,这样静态网站就能访问index了