Home ยป Micro
Crafty micro logo

Pagefind From CloudCannon

A lovely self-hosted site search for SSGs like Hugo
July 3, 2023 1 min

After fixing my image processing woes, I decided to tackle site search. I actually have enough content between larger essays and smaller micro formats that I’m having trouble finding my own stuff.

I surveyed the field, which included local JS options such as lunr.js and fuse.js, as well as external options like Algolia. Then I decided to check what Bryce Wray uses. It turns out that Bryce uses Pagefind from CloudCannon, and he wrote extensively on why. Sold!

Pagefind is designed for Static Site Generators (SSGs) like Hugo. The way it works is, you first run the normal Hugo build, which generates all of your site’s static HTML; then you follow with the Pagefind build, which indexes that HTML content. At runtime, Pagefind provides some simple JS scripts to hit the index and provide results. It was a straightforward to set it up and then fine-tune the index a bit to get only the content I wanted to show up when searching. You can see it in action here.