Search
Build Index
Hugo already builds indexes of all pages, we can cherry-pick which aspects should be searchable. The result is a newly created JSON index at /index.json
.
We can generate the index.json
by adding layouts/_default/index.json
as followed:
|
|
Add this snippet to your config file to instruct Hugo to create the index file in JSON format. (RSS and HTML are default outputs, what’s important is to add JSON.
|
|
The index.json looks like this, its data structure is defined by layouts/_default/index.json
:
Load Fuse.JS
According to Fuse.JS documents
- Options:
- Fuse.createIndex: Pre-generate the index from the list, and pass it directly into the Fuse instance.
|
|
The data
here is fetched from index.json
, would be an array here:
Trigger Search
|
|
Execute Search
Reference
alipay
Author Houmin Wei
Publish January 24, 2023
LastMod July 11, 2023 (8d68658)
License 本作品采用 CC BY-NC-ND 4.0 许可协议进行许可,转载时请注明原文链接
如果你在浏览博客的过程中发现了任何问题,欢迎在对应文章下评论。如果你有其他事情想要咨询,可以通过邮件联系我。
-
No backlinks found.