Over a year ago, I wrote my own crappy Rails blogging engine and started to use it to power my blog. Today, I moved everything to github. I think it’ll just be easier to write new posts and it’ll make my content more accessible. It also better reflects my general attitude about blogs: less is more.
Github users can create a new repository called
YOUR-GITHUB-NAME.github.com and that’ll be accessible at
http://YOUR-GITHUB-NAME.github.com. For example, my repository is sitting at http://github.com/karlseguin/karlseguin.github.com and it’s accessible at http://karlseguin.github.com/. By placing a CNAME file in my root with the contents of openmymind.net and pointing my domain to 22.214.171.124, things just work.
Your personal page, like a project page, is a special github project though. Every time you commit, github runs your project through jekyll. Jekyll is a blog-aware site generator which supports templating and a few other nice features. With disqus handling comments, anything else is just, well, silly.
Extracting my existing content from mysql was pretty easy:
conn = Mysql.real_connect("localhost", "user", "pass", "db") res = conn.query("select slug, title, summary, body, created_at, id from posts") while row = res.fetch_row do file = Date.parse(row).strftime("%Y-%-m-%-d") + '-' + row + ".html" File.open(file, 'w') do |f| f.write("---\n") f.write("layout: post\n") f.write("title: \"" + row + "\"\n") f.write("disqus_id: " + row + "\n") f.write("---\n") f.write(row) end end res.free conn.close
Now, almost all of my links are still valid (/about turned to /about.html), and publishing a new post involves commit the file and pushing it to github.