Building My Website with Pelican

20 Feb 2016

Or, a rationalization of why I invested a month rebuilding this website.

The first version of my website used WordPress. Although it served its purpose, there were several pain points which made me realize that it wasn't the right CMS for me:

1. Performance

By no means is this website high traffic. Nonetheless I was constantly plagued by poor loading times on the frontend and the backend. Notably, editing posts and managing content were unbearably slow operations. A good portion of this could be attributed to the server performance of my shared hosting plan, however I couldn't justify an upgrade simply because WordPress was not performing.

2. Complexity

I had three pages and six articles. Yet my site was backed by a rather large MySQL database. Migrations and backups involved exporting the SQL data via phpMyAdmin, which was quite tedious. Even extracting my content as plaintext was no trivial task - WordPress has a tendency to mangle the text you input, especially if you use the rich text editor.

3. Security

Reiterating the previous point, WordPress is a seriously complicated bit of software. It ships with a user authentication system and file upload functionality among other features. While useful for others, I barely used these features. Instead, they served as potential attack vectors which needed to be secured. With the constant release of security patches, WordPress also required a level of constant maintenance which I could not provide.

The solution? A static site generator.

Static site generators allow for content to be written in a lightweight markup format and a set of HTML pages to be generated from the content. As you can imagine, this significantly reduces the complexity of servicing website requests - instead of executing scripts and querying databases, the server only needs to return static HTML files. An added benefit is that since all the assets are static, caching becomes trivial.

There's something inherently elegant about the way static site generators work, notably the fact that content lives alongside the website template - it's not hidden away in a database. Much of the appeal to me lies in the workflow that static site generators promote, as it's very similar to the kind I use while developing software. I'm able to use my favourite text editor to edit articles, git to version my files and I can even deploy everything via a terminal. No more SQL databases or admin panels to deal with.

Why Pelican?

Mainly because it's written in Python and I'm quite comfortable working with that. I've already had to fiddle with some of the internals and deploy scripts. Another, albeit small, upside to Pelican is that it uses GNU make with a comprehensive set of targets to handle build automation. In my case, building and deploying is achieved with one command - make ssh. It's an absolute joy.

Every tool has its quirks and Pelican is no exception. I've had to employ a few hacks - which I'll outline in a future post - to get some of the templating to work. Some of the template-related documentation is also a bit sparse and as such requires trial and error or creative Googling to resolve. Definitely not a deal breaker though - the documentation, along with the rest of Pelican, is open source and always improving.

In summary, WordPress is a great, full-featured piece of software. For those who desire a more dynamic website and can fully utilize everything it offers, it works well. If, however, you're looking for something lightweight I'd highly recommend exploring with static site generators - especially Pelican.