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.

1
2exclude: ['vendor']
3

Add Procfile

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

1
2web: bundle exec jekyll build && bundle exec thin start -p\$PORT -V
3console: echo console
4rake: echo rake
5

Add Gemfile

Add Gemfile at the root of the project.

1
2source 'https://rubygems.org'
3
4gem 'jekyll', '2.4.0'
5gem 'rake'
6gem 'foreman'
7gem 'thin'
8gem 'rack-contrib'
9

Add config.ru

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

1
2require 'rack/contrib/try_static'
3
4use Rack::TryStatic,
5:root => "\_site",
6:urls => %w[/],
7:try => ['.html', 'index.html', '/index.html']
8
9run lambda { |env|
10return [404, {'Content-Type' => 'text/html'}, ['Not Found']]
11}
12

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.