A couple of months ago, I went to add a new blog post and realized that my blog page was getting a bit long and overburdened. I decided it was time to start breaking up the articles into pages, and I thought about adding categories and other convenient things. I looked into how I would do this on my own for a bit, but I realized what I was building was simply a static site generator: a script that takes a set of easily editable files (such as Markdown, in my case) and constructs a complete, navigable website from those. The thing is, there are lots of static site generators already out there. In the end, I decided to save some time and use a generator that was already out there.
I read up on a few before eventually settling on Pelican. Here are some reasons why I chose it:
- It should be easy for me to customize.
- It's very lightweight.
- Pelican is designed to be run from the command line on text files you edit with your own editor. This differs from packages like Lektor, which is designed to be used with a GUI.
- Installing and running Pelican from within a virtual environment is a piece of cake.
- Pelican is already fairly well established.
- It's already in use by sites such as Full Stack Python.
- There are a bunch of themes already made out there. This repository maintained by getpelican has 125 examples as of today.
I'm already pretty pleased with the package. Even though I could generate this
whole site in Pelican, I decided not to at first. Pelican cooperated with this
pretty well; simply by setting SITEURL = '/blog'
in pelicanconf.py
I could
get all the links internal to the blog to work correctly.
I was able to make
my own customized version of one of the Pelican themes
without too much difficulty, and I even managed to implement the same kind of
navigation bar that I put on the rest of the site, with a bonus dropdown for
blog categories. I did notice a lot of javascript cruft in the theme I borrowed
from, but most of it was nicely wrapped in blocks that are only enabled if the
corresponding attributes are defined in pelicanconf.py
. They were easy enough
to leave out.
All in all, I feel like it was a good choice, and I would definitely recommend Pelican to anyone else looking for a static site generator, especially to anyone familiar with Python. I'm looking forward to posting more often with a bit more ease and to having some fun tinkering with different functionality.