After migrating from wordpress to a static site, one thing I wanted to re-implement was a search bar functionality. This is tricky due to the fact that static sites have no backend. Pelican has a plugin named pelican-search that uses stork to build a search index for use on the site. One of the challenges is that while pelican-search is still maintained, the maintainer of stork stepped down 3 years ago and it's remained mostly stagnant since. I was able to still get it working, so here's how I did it!
Installing Stork on Windows WSL (Ubuntu)
I primarily use windows, which stork does not have a binary for. I already had an install of wsl so was able to boot into the ubuntu terminal for this.
eric@blog:~$ wget https://files.stork-search.net/releases/v1.6.0/stork-ubuntu-20-04
eric@blog:~$ chmod +X stork-ubuntu-20-04
eric@blog:~$ mv ./stork-ubuntu-20-04 /usr/bin/stork
Now when trying to launch, I got:
eric@blog:~$ stork
stork: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
To fix that:
eric@blog:~$ cd /tmp
eric@blog:/tmp$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
eric@blog:/tmp$ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
eric@blog:/tmp$ stork
Stork 1.6.0
Awesome, part one done!
Installing Stork Search
Back on my pelican blog, with the venv active, a simple pip install pelican-search pulls the pelican-search plugin. I have custom plugins, so I needed to add 'pelican-search' to the PLUGINS array in pelicanconf.py
Installing Static Assets
Due to the main project being unmaintained, I figured pulling the assets to self-host was the smarter choice
export STORKVERSION="v1.6.0"
cd /themes/2026
mkdir -p static/{js,css}
wget -O static/js/stork.js https://files.stork-search.net/releases/$STORKVERSION/stork.js
wget -O static/js/stork.js.map https://files.stork-search.net/releases/$STORKVERSION/stork.js.map
wget -O static/js/stork.wasm https://files.stork-search.net/releases/$STORKVERSION/stork.wasm
I followed the remaining instructions to add the appropriate references to base.html to add the stylesheet and scripts.
Building the Index
In my pelicanconf.py, I add the following to pull all my pages, but skip those that are encrypted.
STORK_INPUT_OPTIONS = {
"html_selector" : ".post-content",
"exclude_html_selector" : "#pec-encrypted"
}
Styling
After that, it was just a matter of customizing the searchbar to fit in on the theme and be mobile responsive!
Final Outcome
When running make devserver or make publish, it automatically will call stork to build the toml and .st files required for indexing each build. It ensures the search index is constantly up to date any time changes are made.