Cloud Lines

CODE IN THE CLOUD

Goodbye Tumblr. Hello, Octopress Powered by Jekyll and Markdown!

For about two years I have been blogging from Tumblr hosted blog. It’s an awesome service and it’s so easy to publish text, photos, audio, video, etc. However, since most of my articles are code related I decided to give Octopress a try, and I love it!

Octopress is a framework for Jekyll, the blog aware static site generator written in Ruby and powering GitHub pages. Octopress adds some sugar to Jekyll, such as HTML templates, CSS, JavaScripts and configuration.

Hence, let me first summarize what I liked about Jekyll:

  • Static: Jekyll generates static HTML pages ready to be hosted anywhere. This means, I can easily host my blog at Github Pages or even Dropbox?
  • Managing posts: It is now much easier to manage my blog posts. I can use the power of my TextMate editor or Bash shell to perform comprehensive operations, such as find/replace, regular expressions, etc, which are not possible with a hosted blog service.
  • Markdown: It allows me to write blog posts in Markdown. No need to mess up with an awful WYSIWYG HTML editor at Tumblr.
  • Git: My blog posts are now in a Git version control system. I can store entire history of my blog on Dropbox or Github. I also can write my posts while offline, preview markdown in TextMate, run Blog locally, and commit to Git.
  • Beautiful code snippets: With a Sass port of Solarized syntax highlighting, Octopress makes it easy to share highlighted code snippets. Moreover, it adds support for codeblock and gist tags (browse through my blog, you will see how great they look!).

So how did I migrate?

Honestly, it took quite a while. Even though, there is a Tumblr to Jekyll script, you will still have to do some manual work. Here are some hints to help you migrate:

  • Setup Octopress, see how to setup Octopress.
  • Follow instructions at Tumblr to Jekyll to get necessary dependencies.
  • Download tumblr.rb that supports Markdown conversion. I had to patch the script since Octopress uses .markdown extensions and for some reason several Tumblr blog posts could not be converted to Markdown, so I had to redirect output of html2text to a file.
tumblr.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--- source/tumblr.orig.rb   2012-03-24 21:58:08.000000000 +0200
+++ source/tumblr.rb 2012-03-26 23:16:25.000000000 +0300
@@ -30,7 +30,7 @@
       posts = rewrite_urls_and_redirects posts if rewrite_urls
       # Second pass for writing post files.
       posts.each do |post|
-        if format == "md"
+        if format == "markdown"
           post[:content] = html_to_markdown post[:content]
           post[:content] = add_syntax_highlights post[:content] if add_highlights
         end
@@ -146,7 +146,7 @@
         content.gsub!(/<#{tag}/i, "$$" + tag)
         content.gsub!(/<\/#{tag}/i, "||" + tag)
       end
-      content = %x[echo '#{content.gsub("'", "''")}' | html2text]
+      content = %x[echo '#{content.gsub("'", "''")}' | html2text 2>> html2md.log]
       preserve.each do |tag|
         content.gsub!("$$" + tag, "<" + tag)
         content.gsub!("||" + tag, "</" + tag)
  • I assume your Octopress blog is working and you are in its root directory. Now, you need to put a modified version of tumblr.rb to the right place and run it:
tumblr.rb
1
2
mv tumblr.rb source/tumblr.b
ruby -rubygems -e 'require "./source/tumblr"; Jekyll::Tumblr.process("http://YOUR_BLOG_URL", format="markdown", grab_images=true)'
  • The script will create Tumblr posts in Markdown format. In order to support old Tumblr URLs, it will also create static pages in post directory with HTML redirects. Let’s move them to the right place in Octopress:
tumblr.rb
1
2
3
4
mkdir -p source/_posts
mv -f _posts/tumblr/* source/_posts
mv -f post source/
mv -f tumblr_files source/
  • Then, I have gone through all pages and aligned the images. I also ran find/replace to all tumblr_files images, which were fetched from Tumblr during migration.

  • Finally, I customized my theme and installed tag cloud plugin.

I might have forgotten something, so if you are in trouble let me know and I will try to help.

Happy blogging!

Comments