Search is an obvious quality of life improvement to a website primarily consisting of information.
Such as this very brain
!
Thus, I embarked to add a search feature to my own zettelkasten theme brain stem
.
The developers of hugo
, to their credit, shout out a few options in their documentation.
So I tried to find more information on a basic implementation with lunr.js
.
This led me to a blog
with info about how to implement this with the addition of only a few files.
Using this blog as a guide I managed to get a working search with lunr
.
This would be fine but then I discovered the most recent commit was from 2020😱.
While this in itself is probably not a big deal assuming the basic feature set is covered,
I have an unreasonable fear of “unmaintained” projects.
Looking for an alternative with a similar use case and feature set led me to minisearch
.
Thus, I then further adapted my own layouts/js to use minisearch
instead.
Given the options around I feel motivated to maybe generalize this feature set to a separate hugo
module.
My main trepidation is that I style everything using unocss
making it less usable for anyone using vanilla css.
The one unexpected caveat of any of these implementations is that the
website needs to have at least a blank file at ./content/search/_index.md
Relevant Commits: