From Wordpress to Octopress
Baked Blogs - not for everyone…
I’ve neglected this blog over the past year or so, and all of the infrastructure. nickt.com was hosted with Media Temple (mt), and a great job they did too. Solid uptime, great communications and extremely responsive customer service (on the rare occasions I had to call upon them for support). However, it was costing me over $600 a year, and while at one time that was ok, my needs have changed and I no longer need a dedicated VPS and complicated hosting.
I’ve used Amazon Simple Storage Service (S3) in the past, but as I was using it to backup gigabytes of photos and videos it started to get expensive and I stopped using it. However, it seemed an ideal place to stick a blog as it’s storage requirements are modest. S3 buckets can be setup to serve static content, which is an ideal way to move away from the complexity of mysql and PHP.
Last week, reading Hacker News I can across Matt Gemmell’s article on Octopress and was inspired to get to a baked blog, and read a few more articles. I quickly setup S3 but the time-consuming part was setting up my client Mac with the Git/Ruby/Jekyll/Octopress environment. Here’s how I did it:
- Installed the latest Xcode from the App Store.
- Installed Macports.
- Installed git from Macports.
- Setup git.
- Ruby Version Manager from Macports won’t install on OSX Lion so I installed homebrew.
- Installed wget from homebrew.
- Installed RVM from homebrew.
- Installed Ruby 1.9.3 (the version OSX 10.7.2 ships with is 1.8.7 and Octopress needs 1.9.x).
- Installed (cloned) Octopress from github.
- Installed the Ruby Gem Bundler.
And that got it installed on two of my Macs. I have the slightly scary setup of using Dropbox to sync across my Macs, and the git repositories are in Dropbox. As I’m the only editor, and the files are small (so very fast syncing), I don’t think it’ll be a problem.
Migrating posts from Wordpress
Now this was trickier. There are basically two options. Use the database and run some sql and hopefully everything will be converted from HTML to markdown. You can read about that here and here or dump the XML from Wordpress and run the exitwp script. There is also a forked version of exitwp.
Initially I couldn’t get the script to work. I found a hint here, and that helped me make the following changes:
parallax:exitwp nickt$ git diff
diff --git a/exitwp.py b/exitwp.py
index 4dd9c83..0aeb6bb 100755
def html2fmt(html, target_format):
- html = html.replace("\n\n", '<br>')
- if target_format=='html':
- return html
- else:
- # This is like very stupid but I was having troubles with unicode encodings and process.POpen
- return html2text(html, '')
+ #html = html.replace("\n\n", '<br>')
+ #if target_format=='html':
+ # return html
+ #else:
+ # # This is like very stupid but I was having troubles with unicode encodings and process.POpen
+ # return html2text(html, '')
+ return html
And after removing that chunk of code I had all of my Wordpress posts ready to move to my new Octopress blog. That said, not everything is clean. Not only are there some formatting errors but not all of the HTML was converted to markup. But, with all the files in a format that mostly works, I can clean them up at my leisure, though if it never happens it doesn’t matter…
Now all I have to do is write more.