Easy Blogging with Rake and Jekyll

Fresh out of College, I read everything on how to make yourself more marketable. Several places suggested, write a blog to get your name out there. However, as a graduate, I was not looking to drop money on a hosted blog or pay for a server to run my own. Also there is something awkward about dot wordpress dot com sites, that just makes people run away from them.

In walks GitHub pages. A useful tool for you to make a simple site for a project, but as you can work on yourself, You could argue that you are your biggest project. So while building this blog I decided to use Jekyll since GitHub will allow me to host it for free on their servers.

In order to make the process easier I created a Rake file too easily create new Posts.

# Ask for title
def ask message
  print message
  STDIN.gets.chomp
end
title = ask('Title: ')

#Create new a post
desc "Default 'rake' command creates a new post"
task :default do
  filename = "#{Time.now.strftime('%Y-%m-%d')}-#{title.gsub(/\s/, '_').downcase}.markdown"
  path = File.join("_posts", filename)
  if File.exist? path; raise RuntimeError.new("File exists #{path}"); end
  File.open(path, 'w') do |file|
    file.write <<-EOS
---
layout: post
title: #{title}
date: #{Time.now.strftime('%Y-%m-%d %k:%M:%S')}
---

Content goes here
    EOS
  end

  # open the file in vim
  sh "vim #{path}"

end

Then to create a new blog post you just run:

rake