Blogging with Pelican
by wurbanski • 22.03.2017 • 3 minutes
Okay, I guess I am a sort of a hipster. I prefer the bottom half of a bread roll to the top one, use SaltStack instead of Puppet, work on my code on Gitlab instead of GitHub and run a static blog on Pelican instead of Jekyll.
To be honest, on a basic level most of static website generators are pretty similar. It's hard to say which one is THE best objectively. I'd like to show why I chose Pelican instead of others and what are it's basic features.
Static website generators have seriously boomed over the last few years, especially with GitHub releasing GitHub Pages in 2008. When I started thinking about finally starting a blog, I was sure that I ddn't want anything based on popular CMS (e.g. Wordpress). I believe in KISS principle so I didn't want to make this too complicated to host and create.
So I found this page showing list of static website generators and their popularity. I thought that this might help me make a choice... Well, at least I had a list to choose from!
I had some bad memories of getting Jekyll and Ruby to work on development environment (I might have been unlucky) so I decided to work with something that I know pretty well - Python-based system. Of those, the most popular is Pelican so I have decided to use it.
The process of starting a development environment is very easy. Assuming that you're using virtualenv (which you should):
Create virtualenv and install required packages:
$ virtualenv my-blog
$ . my-blog/bin/activate
$ pip install pelican markdown
Quickstart the site:
$ pelican-quickstart
After answering some questions, project is waiting for you to start hacking!
my-blog/
├── content
│ └── (your posts)
├── output
├── develop_server.sh
├── fabfile.py
├── Makefile
├── pelicanconf.py
└── publishconf.py
The most popular markup language in today's world. I have always wanted to learn all shortcuts and symbols of Markdown, but I wasn't using those often enough to keep them in my mind for long. Now I have a ~~method~~ to do so. How do I strikethrough? Doh.
Jinja is one of the most popular templating engines in Python, with Mako close and django's templating very similar. I use jinja extensively in my day-to-day work as it's also used as a templating engine in SaltStack management system. Since I wanted to create my own theme for the blog, this was a great boon for me.
There is an exerexpanding library of plugins for pelican available on GitHub. While I still cannot find use for most of them, it's good to have some choice, right?
* I assume that Python is available almost anywhere nowadays.
It's very easy to build the site and run a development server. Just activate the virtualenv you're created earlier and then run make devserver
. Or, if you don't have make available, install fabric (pip install fabric
) and run fab serve
. Then just open http://localhost:8000
and view the results.
I feel that the documentation is sometimes lackluster in examples showing how to do some things - especially regarding theming. But I have to admit that all possible configuration options are there and described correctly.
This was just some basic information about a viable and fun to use alternative to other static website generators. I'll surely get back to this topic later on, with some hacks, features and my favourite plugins.
Feel free to share your experiences and opinions about static websites versus typical CMS-based ones.