I Almost Switched to Pelican, a Static Blog Engine

Visitors familiar with my blog will notice a pretty big change when viewing this post. The blog’s been due for a redesign for some time now, so a few days ago I finally went through with it.

The redesign took more time than expected, since I spent quite a lot of time setting up Pelican — a static blog engine written in Python, including converting all my Blogger posts to Markdown. I will describe some of the reasoning behind this, together with the reason why I ultimately stayed with Blogger — for now.

What’s Wrong with Blogger?

I’ve been using Blogger for many years. Delving into the archives of this site suggest I’ve been seriously using it since 2005, with my main blog being called “Macuyiko’s Mindcube” back then. In fact, it’s still online, with the last post redirecting visitors to my new blog (“Bed Against The Wall”).

Throughout the years, that — this — blog went through a series of redesigns and shifted through topics of interest. To be honest, I was never that good at consistently putting out content, but being able to keep the thing running for almost ten years now is an accomplishment in itself, I suppose.

Anyway, I’ve been getting somewhat disappointment with Blogger lately, something which started some two or three years ago, when I started putting out longer articles, containing also more code fragments. Don’t get me wrong, I don’t think Blogger is bad, but the following things were becoming an annoyance:

  • I’ve seen my fair share of Javascript WYSIWYG editors — either bolted to your favorite blogging platform of choice or “that PHP Content Management System from the nineties”. While libraries and frameworks such as JQuery have helped to clear out some of the mess, I honestly feel that 99% of them still behave like crap.

    I’ll not go into details about all the things wrong with Javascript editors now. Still, there is one silver lining which is worth mentioning: the amount of great Markdown based Javascript editors which have appeared during the past years. For example, check out EpicEditor, markItUp!, markdown live editor, WMD (outdated) and its many spinoffs. I absolutely love Markdown, and have even forced it to users of websites I’ve built, using one of the aforementioned Javascript editors to make it clear how easy it is to write Markdown text.

    At this point you might be wondering what, exactly, is so messed up about the Blogger WYSIWYG editor. There isn’t anything really wrong with it, but the following has been bothering me:

    • Inserting code is a problem. You have to deal with pre, tt, code tags together with installations of Pretty Print (or similar libraries). Don’t forget to convert your <s to &lt; or things won’t work. Make sure your whitespace is correct, meaning that you alternate between tabs, spaces, or a bunch of &nbsp;s.
    • So okay, maybe Blogger isn’t great for code, but at least it’s perfect for writing, right? Not really. It’s okay, but the rise of recent “modern magazines” such as Medium and SVBTLE have made it clear that writing can be a much smoother process. Heck, even Wordpress’ editor is nicer, and will apply many typographic fixes such as converting two dashes to an em-dash.
    • Blogger allows too many formatting options. Since its editor is a WYSIWYG on top of HTML, it’s perfectly fine to copy-paste in ugly text coming from an e-mail message or that Word document you typed out… <span> with mso-style, anyone? Please, just allow me to apply headings, emphasis, lists and paragraphs to my text, but let the theme CSS do its thing and leave out the styling.
  • Making changes to the template is bothersome. Blogger’s template system is fine as long as you keep using one of the default themes, maybe make some slight color or font changes, and leave the rest as is. Once you want to start moving stuff around however, add backgrounds or lots of custom CSS/JS, things get harder and you quickly and up in the middle of “tag soup”. I didn’t even manage to change the background of the final theme I was using once, even though I was initially planning to do so once in awhile. It’s not hard, but my laziness outshines the difficulty.

That said, there are plenty of things which I do like about Blogger. It’s very easy to set up a basic blog, there are many widgets to choose from, basic templating stuff is fine if you don’t mind your blog having a common look and feel. Also, comment management and moderation works pretty well, especially now with the Google+ integration.

So, in short, what I wanted was:

  • The ability to write in Markdown
  • The ability to easy add in code, syntax highlighted if possible
  • Nice typographic options, beautiful text
  • Easy theming support

Blogger was starting to make this pretty hard.

Solutions, Workarounds and Alternatives

Just continue to use Blogger?

I’m not alone in my desire to use Markdown with Blogger. The topic has actually been discussed to a great extent, with solutions including the following:

  • Write Markdown on your computer, then convert to HTML with one of many tools out their. Cons: redundancy, no central “post” repository, making edits is hard. Not 100% web based.
  • Use one of these neat apps such as Byword (MarsEdit as well?) which lets you publish to Blogger. Cons: not 100% web based, no central posts repository. Often Mac only…
  • Write a web app using Blogger’s API which would allow me write posts using Markdown and publish them to Blogger after converting them to HTML. But this would’ve taken so much effort.
  • Include a bunch of magic Javascript scripts/parsers on your Blogger blog which will perform the conversion of Markdown to HTML client-side. This keeps your posts centrally stored, but relies on too much hacks to feel like a great solution. Still, it’s being used. mmd.js seems to be the preferred Javascript Markdown parser as of now.

Switch to another service

There has been a renaissance of writing on the web. When 2012 used to be about Tweets and short status updates, sites like Neocities or Medium are putting the emphasis back on simple, well written web sites.

Indeed, the options for a minimalistic blog are many. Many of them support Markdown out of the box. Many of them do away with many typical overblown blogging features. No comments, no complex theming, just writing:

I will admin, these all look fantastic. I’m already using Tumblr for my random stuff I find online blog; the Dropbox based options look like great Zen-like blogging experience. I have my invite for Medium, and the platform looks fantastic.

I would’ve gone with one of these options (in fact, I’m still on the fence), but I was a bit disappointed with (i) the lack of code formatting support on most of these platforms, (ii) the lack of any theming to make yourself stand out.

Host it yourself, static-like

A final alternative solution I was considering was hosting the blog myself using a static blog engine. I don’t mind Wordpress, but think it’s completely overkill for a simple use case such as mine. I considered the following options:

  • Jekyll: Ruby, Markdown or Textile, robust, proven, powers GitHub Pages…
  • Octopress: sits on top of Jekyll to provide a more full featured blogging platform.
  • Hyde: “Jekyll’s evil twin”. Python, Jinja2, full-featured.
  • Hakyll: Haskell, robust, esoteric.
  • Acrylamid: Python, Markdown and reStructuredText, Jinja2. Fast, experimental.
  • Utterson: Unix, HTML. Basic, experimental.
  • Rog: Ruby, simple, young.
  • Cyrax: Python, Jinja2, young.
  • Second Crack: PHP, one of the few PHP static blogging engines worth mentioning these days (shows how the language has evolved, actually…). Created by Marco Arment, so you know it can hold its own. Not suitable for everyone though.
  • Pelican: Python, Jinja2, Markdown and others, well-featured, easily usable.

Ultimately, I settled on Pelican. I liked Jekyll, but wanted a Python based engine since I didn’t want to deal with installing Ruby on the server I’d be using. Installing Pelican is very simple. Just pip install pelican, Markdown and typogrify and you’re set. Typogrify is a great Python library which helps you to prettify written text, mostly thanks to Gruber’s fantastic SmartyPants plug-in.

Configuration is just an easy step consisting of modifying pelicanconf.py:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals

AUTHOR = u'Your Name Here'
SITENAME = u'Your Title Here'
SITEURL = ''

TIMEZONE = 'Europe/Brussels'
DEFAULT_LANG = u'en'
TYPOGRIFY = True

# Generation
DIRECT_TEMPLATES = ('index', 'archives')
MONTH_ARCHIVE_SAVE_AS = 'archives/{date:%Y}/{date:%m}/index.html'
YEAR_ARCHIVE_SAVE_AS = 'archives/{date:%Y}/index.html'

# Feeds
FEED_ATOM = 'feeds/atom.xml'
FEED_RSS = 'feeds/rss.xml'
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None

# Blogroll
LINKS =  (('Name', 'http://url.com/'),
    )

# Social widget
SOCIAL = (('Twitter', 'http://twitter.com/username'),
     )

DEFAULT_PAGINATION = 10

# Template
THEME = "themes/custom_theme"

I then picked the TuxLite ZF theme from pelican-themes as a starting point to put in custom_theme. I changed the color scheme, header sizes and spacings and fonts (making use of Google’s web fonts to pick out a nice heading font which would work well with large-sized OpenSans for the normal text, which I’m currently in love with — it works great for slides as well, try it!). Editing the Jinja2 themes was a breeze and mostly consisted of taking stuff away — like tags and categories — which I didn’t need. Finally, I made sure to made the background “pop” behind the single-column content, using inspirational, high resolution foto’s.

Next up, the hard part, converting all my Blogger posts to Markdown… Luckily, Lars Kellogg-Stedman has had the same problem and describes possible approaches in this post. I thus created a folder with the following:

  • blogger2md.py from https://gist.github.com/larsks/4022537
  • blogger-export.xml from Blogger: an export of your blog
  • html2text.py from https://raw.github.com/aaronsw/html2text/master/html2text.py

You’ll need to install lxml to get everything to work. This didn’t work for me using pip, but easy_install did the job. Once this is setup, create a new directory posts and run:

blogger2md.py --html2text --output-dir posts blogger-export.xml

The script will start crunching and convert everything. Afterwards, I went through every post to rename the file name, correct the meta data, fix the links (Pelican wants (|filename|FILE_PATH)) and clean up some formatting issues still present after the conversion (quite a lot of them). This took a few evenings, but I now have a collection of Markdown posts for this complete blog.

Side track: a trip down memory-lane

While I was converting all these posts, it struck me how long I’ve been blogging, and how “face-palmingly” bad my writings were as a kid. Luckily, my Geocities page has since long disappeared thanks to Yahoo! (actually, I should retrieve it from the archive for a laugh), but this wasn’t that much better. “This dog is gonna check out town”… really, young me? I wanted to keep everything intact, but made some modifications to the language where I really felt I had to (swearing, “hackz0r M$”-bashing, referenced to piracy… hey, I was a poor kid).

It’s also funny to see the topics my blog has shifted through:

  • Games, with sad reviews of “classics” such as Scarface… and Portal.
  • Linkdumps, oftentimes based on what I’d read on Digg (yes, Digg!) that day. Is Digg still around? I almost forgot about the HD-DVD “number gate” back then.
  • Linux related posts. Mostly following after acquiring my now pre-historic Thinkpad X60 which is, in fact, still somewhat being used.
  • Hacking and thinkering… like here and here. Some of these are not that bad. The Kippo article has been pretty popular, together with the PalettestealerSuspender tool. Others just show off my horrific PHP skills.
  • Puzzles, algorithms, optimization. I like these as well, but they should be proofed for language, spelling, formatting.

Anyway, back to the main programming now.

Just stay with Blogger?

So here I was, ready to launch with Pelican. Admittedly, some of the posts needed some further formatting, some links has to be corrected and the Disqus comment system had to be implemented, but that could be done later. All there was left to do was relink the domain name (blog.macuyiko.com) and put up a message on the old blog that things had moved.

Still, I wasn’t feeling sure about things. Just to be sure, I decided to have another look around to see if things had improved on the Blogger side as of yet, since it’d been a while since I’d searched for solutions.

Turns out there is a web app called StackEdit which provides a great Markdown writing environment, is able to sync to Dropbox or Google Drive (sweet) and is able to publish to Blogger. Alright, maybe one more chance, then. I spent some time revamping the old theme to match the design I’d put together for the static site (you’re probably looking at it now), using the same fonts and colors. I had also set out to be able to change the background every time I made a new post, so I made sure I’d be able to do that from now on as well. That’s why you’re currently looking at a summer-y “pelican” background. It’d be great if I could made the background post-dependent, but maybe that’s going too far.

So I’m keeping things a bit longer with Blogger. As I said at the beginning, it offers some nice features, and this way I don’t have to introduce yet another commenting system.

On the plus side, I’m now able to write and keep posts as Markdown (using StackEdit with Google Drive) and host at Blogger. The theme doesn’t look too bad (will need some further fine tuning) either. Still, if it turns out that I’d rather go to Pelican anyway (or maybe one of the services mentioned above), I now have a collection of Markdown posts at the ready.

I realize this post didn’t really offer any information. I guess this was an exercise in keeping things the same while still putting in lots of work. Still, it was nice reading up about static blog engines, and I’m still pretty intrigued by these hip, new services (Blogger certainly feels like the old guy in the block). In addition, the refresh of the Blogger theme has been inspiring in trying to conjure up some new content, so the remainder of the year will see the arrival of some other posts as well — so long as this experiment goes right, this is a first test post after all. I should still go through the older posts to clean them up, but we’ll see what we can manage.