PaperMod 已集成 Fuse.js 实现搜索功能,本篇记录下如何使用

1 新建页面

1
hugo new search.md
./content/search.md
1
2
3
4
---
title: "搜索"
layout: "search"
---

2 修改网站配置

./config.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 添加搜索菜单
menu:
    main:
        - name: 搜索
          url: search/
          weight: 10
params:
    # 添加搜索参数,参考 https://fusejs.io/api/options.html
    fuseOpts:
        isCaseSensitive: false
        includeMatches: true
        shouldSort: true
        location: 0
        distance: 1000
        threshold: 0.4
        minMatchCharLength: 0
        keys: ["title", "permalink", "summary", "content"]