Blog

Why I switched to a static site generator

Back in 2012 I decided it was time to get myself a blog. I had been doing web development for a while but didn't have a personal website and thought a blog would be appropriate. After some research I opted to use wordpress since it was so popular. I figured I could save time by using plugins and freely available themes, rather than roll everything by hand.

Last night I ported my blog to Pelican: A static site generator written in python. So far I'm happy with my decision and here is a list of why I switched over:

It's Lean

Wordpress is written in php and required me to install php5 and other php packges on my server (php5-mysql etc.). It also required me to install a database (mysql) in order to get it up and running. Since I use nginx as my webserver I also had to use php-fpm to serve my php files.

For pelican, I only needed to install the software locally. It doesn't require any additional software on the server since it outputs directories and html. I don't have to worry about process management or available ports on my server.

Python

Pelican is written in python which means I get to use virtualenv and pip install all my favorite packages. I also get to use python which always makes me happy. I personally do not like php but that is just a personal preference.

Writing Posts

In wordpress, I had to login to the physical site and write articles directly via the backend. I found it to be a bit sluggish and I have alwas disliked TinyMCE and other online text editors. With Pelican I can write my posts in sublime in my linux vm using markdown. I don't have to worry about losing connection mid-post or dealing with TinyMCE and its html formatting.

Deployment

When I'm ready to publish my post, I just run the fabfile I created (fab make && fab deploy) and the site gets updated. My fabfile is only about 10 lines and simply commits my content to the git repo for my project, builds the html with pelican then scp's the files to my server.

Themes

wordpress has tons of available themes which is a great selling point. However, I never got into themeing as it has a bit of a learning curve; with pelican I jumped right in using jinja2. To be fair I have spent a lot of time with django so jinja2 came quite easily.

Pelican makes it very simple to make new themes, however there could be more documentation on the web about the process. Luckily I have experience with python frameworks so I was able to pick it up easily but I can imagine it being more confusing for those with less experience. I might do a little tutorial on it soon.

Pretty URLS

At first, I was sad I was going to lose pretty urls without those ugly .html extensions. However, pelican has a clever system which allows you to generate your html in a way such that you can still achieve the same effect. Pelican lets you output files like so:

/post/this-is-my-post-slug/index.html
/post/another-post-slug/index.html

So you still get those pretty urls!

Conclusion

While I am happy with my decision to switch over, I acknowledge that there is still a place for engines such as wordpress. If I ever needed any sort of dynamic behavior then I wouldn't be able to use pelican, even a simple contact form can't be done without javascript magic.

However, as a simple blogging platform to make infrequent posts, I love it. It's lean structure suits my uncomplex needs. Writing/Deploying posts in my native development environment is much more fluid and intuitive than having to log into a fancy backend (one less username/password combo to remember!). Furthermore, all my posts are backed up in a git repository which makes versioning super simple.

Pelican