In Search Of
Since resuming blogging I’ve been looking at a few minor upgrades to improve the UI where it fits with my sense of simple. Adding the ability for readers to comment might be a bridge too far as it brings up memories of previous platforms where commenting was built-in providing me with full-time employment swatting spam and trolls. No thanks. But the ability to quickly search the entire site to find something seems like a reasonable upgrade. The only downside, I didn’t want to use an external search engine product to do it.
Enter Pagefind:
Pagefind is a fully static search library that aims to perform well on large sites, while using as little of your users’ bandwidth as possible, and without hosting any infrastructure. The goal is that websites with tens of thousands of pages should be searchable by someone in their browser, while consuming as little bandwidth as possible. Pagefind’s search index is split into chunks, so that searching in the browser only ever needs to load a small subset of the search index. Pagefind can run a full-text search on a 10,000 page site with a total network payload under 300kB, including the Pagefind library itself. For most sites, this will be closer to 100kB.
I spent all of five minutes adding the feature to the site. See it in action up top of the main page, go ahead, type in a few words and watch the results. I simply installed it, ran a script to build the site index, and it worked without additional configuration. My site is entirely based on static HTML files and this tool indexes every word then provides a little Java scripting to cough up a search query and results window. There are some additional configuration options available, and perhaps I will dig into those one of these days, but it worked the way I wanted from the get-go. That it did that without Google is even better.
Hat’s off to the developers and maintainers!