How to deploy jekyll site to heroku

Neeraj Singh

Neeraj Singh

April 27, 2014

jekyll is an excellent tool for creating static pages and blogs. Our BigBinary blog is based on jekyll. Deploying our blog to heroku took longer than I had expected. I am outlining what I did to deploy BigBinary blog to heroku.

Add exclude vendor to _config.yml

Open _config.yml and add following line at the very bottom.


exclude: ['vendor']

Add Procfile

Create a new file called Procfile at the root of the project with following content.


web: bundle exec jekyll build && bundle exec thin start -p\$PORT -V
console: echo console
rake: echo rake

Add Gemfile

Add Gemfile at the root of the project.


source 'https://rubygems.org'

gem 'jekyll', '2.4.0'
gem 'rake'
gem 'foreman'
gem 'thin'
gem 'rack-contrib'

Add config.ru

Add config.ru at the root of the project with following content.


require 'rack/contrib/try_static'

use Rack::TryStatic,
:root => "\_site",
:urls => %w[/],
:try => ['.html', 'index.html', '/index.html']

run lambda { |env|
return [404, {'Content-Type' => 'text/html'}, ['Not Found']]
}

Test on local machine first

Test locally by executing bundle exec jekyll serve.

Push code to heroku

Now run bundle install and add the Gemfile.lock to the repository and push the repository to heroku.

If this blog was helpful, check out our full blog archive.

Stay up to date with our blogs.

Subscribe to receive email notifications for new blog posts.