local_search
local_search 用于配置站内搜索功能,非常实用的功能,建议开启。开启后,头部导航栏右侧将出现搜索按钮。
通过输入关键字,可完成对博客站点内所有文章进行搜索匹配。
yaml
local_search:
enable: false
preload: false # Preload the search data when the page loads
enable
enable 是否开启站内搜索功能,可选值:true 或 false。
站内搜索功能配置流程:
在 Hexo 项目根目录下安装插件
hexo-generator-searchdb。bashnpm install hexo-generator-searchdb在 Hexo 配置文件
_config.yml里添加如下配置项。yamlsearch: path: search.json field: post content: true format: striptags主题配置文件
_config.yml的local_search.enable配置项的值设为true。yamllocal_search: enable: true
站内文章搜索效果图:

preload
preload 设置是否在使用搜索功能前进行预加载搜索数据(建议启用)。