As you may or may have noticed, some things have shifted around a tiny bit on these very pages: A while back, I quietly relaunched the site without much fanfare.
The visible changes are subtle, to say the least. The link colour is slightly different, the menu changes a little differently on smaller displays (or with a resized browser),
<code> tags are highlighted a little differently, and that's largely it. Oh, and the usual RSS Feed hiccups of course.
Frankly, there were no pressing reasons. The site worked and used a lot of caching, so the effect of the kerfuffle concerning Heroku performance a while back was negligible.
Sometimes you just need change for change's sake. I like fiddling with technology and this blog has, in its 13 years of existence in one form or another, always been a technology testbed and playground for me.
This time is no different. I had a keen interest to play with static site generators and my own blog application wasn't special enough to keep it running just for sentimental reasons.
But, why Middleman?
Middleman is one choice out of many when it comes to static site generators.
In the Ruby world, apart from Middleman there's Jekyll, which powers, among others, GitHub Pages and recently went 1.0. Then there is Octopress, which is an add-on for the aforementioned Jekyll and offers some nice bootstrapping options.
Middleman convinced me with a solid plugin architecture, not too many defaults that make it all obvious which tool you used to create your site, and a sensible approach to the "writing offline with previews" workflow. Some of the other contenders performed well in some of these areas but fell short in others.1
To reduce complexity, I also switched from Compass and Susy to Twitter Bootstrap2 as the framework. That means I had to port the grid and individual components over, which turned out to not be too hard.
Likewise, my backend implementation to extract captions of
Lastly, syntax highlighting is still handled via Pygments internally, but the interface to it is no longer my original implementation that is called after saving an article to the database (since there, well, is no database). Instead, I'm using Rack::Codehighlighter, which Middleman can easily cooperate with.
Middleman and Blogging
Middleman itself is setup pretty well for serving as a blog by way of the official blogging extension.
This extension gives you the usual suspects like a bunch of articles in reverse chronological order, tags, calendar pages, drafts, the whole nine yards. You could even run the blog integrated as a sub-directory into a regular corporate site with lots of static pages, not unlike Squarespace offers blogs as page types alongside its regular pages.
The workflow to write a new article (or create a new static page) is to simply create a file with a supported template extension (I use
.markdown) within your
In order to keep my templates separate from the actual articles I moved the source directory for the articles to
source/articles/ instead of the default option of putting them directly into
# config.rb activate :blog do |blog| # .. blog.sources = "articles/:year-:month-:day-:title.html" end
Instead of creating the file manually, Middleman offers a handy shortcut that converts the article title to a permalink and also prepends the date:
$ middleman article "My new Article" create source/articles/2013-02-25-my-new-article.html.markdown
With this file in place you can open it up in your favorite text editor and start typing. When you're ready for a preview, start
middleman server and point your browser at
http://localhost:4567. Assuming a typical blog homepage with articles displayed in reverse chronological order, your new article will show up at the top. Clicking the link will open the detailed article page such as
Since Middleman integrates with LiveReload, every time you save the file in your text editor, your browser will recklessly reload to show you the latest changes. Especially for more sensitively arranged articles with lots of images and/or code samples this is a godsend.
Speaking of drafting articles, Middleman supports a
published: false attribute in its Frontmatter, which will exclude those articles from being included when you build the site.
I’m planning to publish additional articles covering blogging from an iPhone or iPad in conjunction with a static site generator in the weeks to come.
Also, there are a few tweaks I need to make to improve building the blog and publishing it to S3 in the least amount of time possible, which is a challenge I gladly accepted.