Skip to main content

A tweak to how I use Pagefind

Nov 27, 2024

I have been using Pagefind on this site for some time to handle site search.

I was finding that some searches turned up pages and posts that had more results than made sense, i.e., the results were overly broad. For example, prior to the tweak that I'm about to describe, a search for the word "doing" would return any word with "do" as its stem.

This was raised on Mastodon. I chimed in.

Liam Bigelow, the author of Pagefind, showed up and shared a way to tone down the results, which I implemented. In short, Liam said "For sites where it isn't performing well, a current escape hatch is to use --force-language unknown when indexing, which doesn't perform any stemming at indexing or query time."

All I had to do was add --force-language unknown to the indexing commands in my package.json file, one for local development and one for production. I did that and reindexed the site. Now, the search results are much more in line with what I expect.

If you've had the sense that Pagefind search results were overly broad, give this a try. It worked for me.

Send a comment by email (yes, that's a mailto link).