Skip to content

Instantly share code, notes, and snippets.

@sukima
Created August 24, 2010 19:57
Show Gist options
  • Save sukima/548192 to your computer and use it in GitHub Desktop.
Save sukima/548192 to your computer and use it in GitHub Desktop.
Rake task for making a new Jekyll blog post
desc "Create a new blog post"
task :blog do
print "Please enter in the title of the blog post: "
title = $stdin.gets.chomp.strip
name = title.gsub(/\s+/, '-')
name = name.gsub(/[^a-zA-Z0-9_-]/, "").downcase
time = Time.now.strftime("%Y-%m-%d")
File.open("_posts/#{time}-#{name}.markdown", "w+") do |file|
file.puts <<-EOF
---
title: #{title}
layout: post
tags:
---
EOF
end
puts "Created '_posts/#{time}-#{name}.markdown'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment