##Hero… what?

After two years using Jekyll for this tiny blog, I am still on it and loving it. But I spent enough time managing a litlle vserver on which I deployed my blog using git hooks. Everything was working as expected. But managing a vserver, securing it and keeping it up to date is a real time sink. Many time I said to myself: you should be coding (and not upgrading your distro).

Some time ago, I decided to give Heroku a try. Damn! What they did with their platform is pure genius! Basically you can build and deploy your app using a simple git push command. They work using the abstraction of a dyno defined as:

A dyno, the basic unit of composition on Heroku, is a lightweight container running a single user-specified command So a dyno will take care of your web request or your background job or anything you throw at it. You want a more scalable app? Increase the number of dynos and you’re done. Now the best part, Heroku offers you one dyno for free each month.

So I settled on the plan of deploying this Jekyll blog using the free Heroku dyno. As you can imagine, I am not the first having this idea, see:

… and many more I saw. These guys are all awesome and their projects are great. But what I had in mind for this blog deployment was to keep it simple, using this idea: I can generate a static site locally using the jekyll command, I just want to be able to upload this static site on Heroku. I don’t see why the site generation should take place on Heroku. So I settle to upload a static site on Heroku and it was dead simple after reading this.

##The 2min step-by-step ultimate guide for deploying a Jekyll site on Heroku without any pain

You don’t like long titles?

  • In the root of your site, add a Gemfile with
source :rubygems
gem 'rack-contrib'
  • Run
$ bundle install
  • Add a config.ru file with ```ruby require ‘rack/contrib/try_static’

use Rack::TryStatic, :root => “_site”, :urls => %w[/], :try => [‘.html’, ‘index.html’, ‘/index.html’]

run lambda { [404, {‘Content-Type’ => ‘text/html’}, [‘Not Found’]]}


* I like setting the exact command that will be run by the dyno, add a Procfile with

```bash
web: rackup -p $PORT

You’re done! How to test? Actually you have two ways of testing your config:

  • Using foreman (which is part of the Heroku toolbelt)
$ foreman start
  • Using the rackup command
$ rackup -p 4000

Once everything is ok, deployment is a piece of cake, once you have initialized the app on Heroku:

$ git push heroku master

You’re done! You can watch the result

$ heroku open

Tadaaaaaa! Cookies time!