I partially write this blog for me, for future reference, partially to help others who encounter similar issues and to lesser extent to have a link with well-formed thoughts that I can share instead of having to come up with lengthy explanation in situ.

When I needed to refer to an old post I used to do a Google search with the site:jan.alphadev.net operator and a keyword, but for years now it had stopped working. Google indexes only a small portion of the page even though all posts and pages are listed in the Sitemap and are properly reachable. Google’s Search Console isn’t of any use either.

Meanwhile I did grep the Markdown sources for this blog for the thing I needed, which worked but doesn’t work on mobile and can only be done by me.

Yeah, well, I’m gonna go build my own theme park. With blackjack and hookers! In fact forget the park.

Bender

The plan to finally add my own search has been percolating in the back of my head for more than a year and I had even started to experiment with pagefind, but I never got the integration into Jekyll working properly1.

This morning I stumbled over this post by Stephan Miller, that described how lightweight and easy the implementation using Lunr.js is, and now… I do have my own search index.

I opted go all the way by pre-computing the entire index during build-time and then push it along with the rest of the static files. (/assets/index.json, if you’re curious). At the time of writing the entire index is approximately 1.2 MB in size. But is only loaded when you visit the /search page.

Both Lunr itself and the index are loaded from this domain2 and once successfully loaded, work entirely offline. No requests are sent anywhere.

The only downside are the 1.2 MB initial load and the requirement for working JavaScript. But it is still way better than having to grep Markdown files.

Supposedly there are all kinds of smarts that can be enabled during index creation, I have left everything default for now, but let’s see how long that lasts.

  1. Have I mentioned that I dislike the way Ruby feels? Their whole premise is DX, but I just can’t get accustomed to it. It is just not for me. 

  2. Yes, I know, technically GitLab Pages underneath