0%

Next主题添加搜索功能

前言:Next主题添加搜索功能

1.安装插件

在hexo的根目录下执行命令

1
npm install hexo-generator-searchdb --save

2.添加配置

在站点配置文件最后添加配置:

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

3.修改配置

在根目录下的/theme/next/_config.yml文件中搜索local_search,将enable改为true

1
2
3
4
5
6
7
8
9
10
11
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
# Unescape html strings to the readable one.
unescape: false
# Preload the search data when the page loads.
preload: false
-------------本文结束感谢您的阅读-------------