Pelican
Since 2014, this website has always been a WordPress site. Until now! I just converted it to a static site, powered by Pelican. Pelican is a static site generator, written in Python. I converted all the posts from the old site to markdown using the wordpress-export-to-markdown tool, which then required a little massaging to get into shape for deployment.
To install Pelican, all I had to do was:
pip install "pelican[markdown]"
pip install pelican-render-math
The site is configured using a pelicanconf.py
script. Once that is set up, building the site is as simple as:
pelican content
And that's it. It generates only HTML files, which can then be uploaded to the web server. For that I followed the instructions here to set up a GitHub Action to do this automatically. I also made an .htaccess
file to redirect all the old WordPress URLs to the new ones, so old links on other sites to this one will still work.
All in all, it works pretty well. I did lose the comments, but I think it's probably worth it since it makes maintenance so much better. The site is now a set of simple markdown files, which I can easily edit locally, and even view the results in Pelican's simple built-in web server. Everything is backed up to GitHub (currently this is in a private repo). And I don't have to worry about keeping WordPress up to date, databases getting corrupted, or a PHP update breaking everything. Pelican themes and layout options are not as sophisticated as WordPress, but I will continue to tweak things over time.
See also
- Pelican Static Site Generator, Powered by Python
- Zell Liew, Deploying to a server via SSH and Rsync in a Github Action, March 17, 2021