Implementing Search for Hugo

Fuse.js

Fuse.js is optimized for smaller collections of documents: it uses the Bitap algorithm, that provides good fuzzy matching, but iterates through the whole collection of documents upon each search. For this reason it is not ideal for my use case, where Fuse.js incurs in a noticeable delay. Despite this shortcoming, for small collections Fuse.js works quite well and is easy to use.

Lunr.js

Lunr comes with stemming and language support. MiniSearch provides the facilities to add those, but does not provide them out of the box. Stemming and language support are useful features, but they are often not needed, make the library bigger, and can sometimes lead to unexpected results

Lunr index cannot be changed after creation. MiniSearch instead makes it possible to add and remove documents to the index at any moment.

Hugo Fast Search

Fast Hugo search option with:

  • Minimal / zero external dependencies (no jQuery)
  • Smallest possible size added to each page
  • json index only delivered when needed (further minimizing overall impact on page speed / user experience)
  • Keyboard friendly, instant navigation

Related