I love Jekyll. It’s simple, fast, and secure. It’s also lacking in databases though (unlike WordPress), which makes search slightly more challenging. There are a few options for setting up site search in Jekyll, but one is ultimately superior: Lunr.js.

Lunr.js is a simple, open-source (read: free) option for adding search to static sites. It runs on the client-side (in-browser), and using some Jquery magic, it returns results in real-time. No need to press a search button.

There are a number of ways to actually use Lunr.js with Jekyll, but the easiest I’ve found is this open-source plugin. The whole setup process requires copy-pasting 4-5 code snippets into your gemfile, _config.yml, and default.html, and running a few things in the command line. The process took me 20 minutes. Once it’s set up, it will re-index your search engine automatically whenever you update your site. It’s also super-easy to customize the user experience with just a few more lines of HTML/CSS.

The other option I considered for search was Algolia, a really beautiful 3rd-party search service. They have all kinds of cool bells and whistling (i.e ways to weight/filter searches, data), and a Jekyll plugin. Ultimately though, I couldn’t get it working 100%, and I didn’t need the power they were offering for my little sites. If you’re running a Jekyll site with at least 1000 pages or 50,000 uniques per month, or you need some type of complex search feature, Algolia might be a good option for you though.

For now, Lunr does all I need, offering a really nice way to quickly integrate real-time contextual search.