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