Blogging With Second Crack

  • Share:

This blog has existed for awhile, but I never really dedicated myself to posting regularly. That changed recently and I would like to share my new workflow.

Motivation

A big reason for the site’s stagnation was that the process of publishing was pretty cumbersome. In the past I used a self-installed version of WordPress on a HostMonster shared-hosting plan. That setup was less than ideal:

  • To post new content, I needed access to a web browser for the built-in editor.
  • The editor was flakey on the desktop and just plain unfriendly on the iPad.
  • While there is an iOS WordPress app, it was impossible to use for my needs.1
  • WordPress heavily uses PHP/MySQL, which hurts when traffic is high.
  • Even with a cache plugin installed, the site load times still felt slow.2
  • Customizing themes was a pain, especially when the author issued an update.
  • The content was stored in a database, which left me worried.

All of this isn’t to bash WordPress or HostMonster. I think both offer really great tools that work for most people. I just felt it was time to move to something new.

Static

For the new setup, my needs were speed and portability. Initially, I found a great solution proposed by Brent Simmons to make a blog that only served static files. Such a blog is lovingly referred to as baked. The impetus is that server load is greatly reduced when only dishing out static text files as compared with database-intensive systems like WordPress.

The baked system was presented as a generic idea, so it took a post on practical implementation by Matt Gemmell to convince me. Gemmell chose to go with Octopress for his backend. I opted instead for Second Crack, a static-blogging engine recently released by Instapaper creator, Marco Arment. More on that decision in a bit.

Hosting

Changing hosting plans also aided the goal of speed. Gemmell previously suggested Linode3 for hosting. A request to Marco for preferences yielded the same. I was sold and decided to start with their basic plan, which has proven adequate. I setup the server using Ubuntu with a basic LAMP stack. Site load times are certainly faster. The true test will occur whenever the blog gets a quick spike in traffic.

What is Second Crack?

Second Crack is described as a “static-blogging engine using Markdown-formatted text files as input.” The idea for Second Crack was first publicly discussed on Marco’s podcast, Build & Analyze. Less than a year later, the public alpha was released via GitHub. After a few days of setup and testing, I switched this site’s backend to Second Crack.

Why Second Crack?

There are certainly numerous static-blogging engines out there, so why Second Crack? I have been an Instapaper customer for several years. During that time, Marco’s dedication to a user-first experience led to an implicit trust. When he first described the idea of Second Crack, I was immediately interested.

Beyond that, I shared Marco’s desire for a system that wouldn’t force social media crap on the user - like commenting systems or link-backs. I wanted a simple tool that allowed me to locally own my content, serve and sync it remotely, and not worry about some database losing it. I also wanted the ability to easily control the site’s design via simple static includes of CSS or Javascript. Second Crack easily met those standards.

My original goals included portability. Since files were written in Markdown, I could write posts in plain text without having to worry about correctly formatting HTML code. Plain text also meant that I could use an almost limitless number of editors.

Migration

In order to migrate to Second Crack, I needed a way to transfer content from the WordPress database to static Markdown files. The first step was to use the WordPress export feature, which created a large XML file. Next, the XML file had to be parsed and written in the correct format. The biggest concern was maintaining the linked-post format used on this site. To do this in WordPress required me to store the external link in a custom meta tag. Unfortunately, most migration scripts didn’t handle meta tags.

I originally tried a script recommended by Gemmell. I was able to hack the code and make it work. Even then, the format wasn’t exactly what I needed and I found it too complex for my needs. I decided to write my own solution. I forked a Gist on GitHub that was close. I rewrote the code specifically for Second Crack. My migration script can be found here. Hopefully it will serve as a clear starting point for you.

How It Works

I won’t recreate the installation steps here. Those can be found in the “README” file. The idea is that you’re web server owns a local copy of the blog in the form of a simple file directory. Second Crack has an updater script that can run either on a schedule via crontab or, as I chose, continuously using inotify-tools.

When the updater detects that you have created a new post or edited an older post in the directory, the corresponding static HTML files are written to your website. The best part is that only altered files are rewritten. Some baked solutions require the entire site to be republished. Depending on the size of your blog, that could be time-consuming.

Dropbox Sync

While Dropbox syncing isn’t required, it is certainly recommended. Again, I won’t go through the installation steps here. Basically, your server runs a Dropbox client. Second Crack is then pointed to your Dropbox folder, which contains your blog’s file directory. This is where the magic lives.

With this setup enabled, I can use any Dropbox-enabled text editor to publish my site. For instance, on my iPhone I can create a post in the blog’s directory. When I save it, the file is synced with Dropbox and downloaded to the server. The Second Crack updater detects the change and publishes the post immediately. I can do the same from my iPad, laptop, or desktop. This truly allows me to write content anywhere.

Another perk is that I can create a post in the drafts folder. Every time I save the draft, it will be immediately available to check in a browser. This allows me to see exactly how the post will look when rendered. Second Crack also contains an optional bookmarklet that grabs text and links from pages you want to write about and stores them in your drafts folder.

In short, the Dropbox sync is highly recommended. It allows you to store a local copy of your site and publish from anywhere. More importantly, it is blazing fast. How fast? Check out this video that shows Marco using the bookmarklet, editing the draft in Dropbox, and then publishing.

Summary

To recap, I switched from WordPress on a shared hosting plan to a static-file system on Linode. I chose Second Crack to serve as my blogging engine. It is fast, reliable, and gives me the speed and portability that I desire. More importantly, Second Crack is a system that gets out of your way. When I used WordPress, the editing system always made me groan and I was aware of the platform. With Second Crack, I am only focused on writing content. The rest is “magic”. It just works.

Should you use it? That depends on your familiarity with Unix and how comfortable you are with administering a server. Second Crack certainly isn’t for everyone. You should also remember that Second Crack is still considered an alpha release. If you read this post and weren’t scared away, then give it a try.

Marco created an awesome system that makes blogging fun and easy, gave it away for free, and continues its development. I have tried to repay the favor by taking an active interest in bug fixes and feature development. If you give Second Crack a try, I would encourage you to do the same. Open source projects are always better when a community takes an interest in its development.

If you end up using Second Crack, I would love to hear about your experience. If you have questions about this post, or any general feedback, hit me up on Twitter.