hexo搜索
安装
npm安装依赖
1
2# https://github.com/LouisBarranqueiro/hexo-algoliasearch
npm install hexo-algoliasearch --save主題配置文件启动algolia
1
2
3
4algolia_search:
enable: true
hits:
per_page: 6_config.yml
配置信息1
Alogolia配置
登陆进入 Algolia 官网,我们可以使用 GitHub 或 Google 帐号登录。然后进入 Dashboard。
左侧
Products
选择 Indices ,新建一个 Index,这里创建了一个名为hexo
的索引Index
(索引)也就是搜索引擎中的数据库,我们所有的搜索相关信息都存在里面。
配置 API Key
配置 Algolia——API Keys 到我们自己的 hexo 站点中,关联两者,使得 Algolia 能够搜集我们 hexo 站点的数据
点击 Dashborad 左侧的 Settings,进入
Team and Access
下的Api keys
.其中的Application ID
、Search-Only API Key
、Admin API KEY
信息将会被用到首先我们需要修改 hexo 站点根目录下的
_config.yml
,进行以下配置:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15algolia:
appId: 'XXX'
apiKey: 'XXX'
adminApiKey: "XXX"
chunkSize: 5000
indexName: 'hexo' # 创建的index名称
fields:
- content:strip:truncate,0,500
- excerpt:strip
- gallery
- permalink
- photos
- slug
- tags
- title在 hexo 站点根目录下执行
hexo clean ; hexo g; hexo algolia
来搜集数据更新到我们刚创建的 Index 中。不清除现有索引
hexo algolia -n, --no-clear
忽略扫描
使用修改的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28npm install git+https://github.com/fulsun/hexo-algoliasearch.git
algolia:
appId: 'XXX'
apiKey: 'XXX'
adminApiKey: "XXX"
chunkSize: 5000
hidden: 'hidden'
indexName: 'hexo' # 创建的index名称
fields:
- content:strip:truncate,0,500
- excerpt:strip
- gallery
- permalink
- photos
- slug
- tags
- title
# 文章配置 hidden: true
---
title: title
date: 2019-07-20 20:10:15
tags: tags
categories: categories
hidden: true
---
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 凉月の博客!
评论