Deploy Jekyll Engine To Heroku

Install Bundler

Make sure Ruby and gem are installed in the system. Bundler is required by Heroku to handle dependency hell. Check the Heroku's sample app tutorial. To install the bundle program, run the following command:

1 gem install bundler
2 % or %
3 sudo gem install bundler

Set up project files

At this time 10/08/2015, Heroku requires rack-jekyll package, the version is 0.4.1. And the supported Jekyll is jekyll < 2.0, >= 0.12.0. If we install Jekyll from command line directly without specifying the version number, a newest Jekyll with version number 2.5.3 will be installed.

rack-jekyll does not support this version, so the Jekyll with version number 2.5.3 should be uninstalled first before process the following steps.

1. Create Gemfile

 1 source ''
 2 ruby '2.0.0'
 4 # For blog
 5 gem 'jekyll'
 6 gem 'kramdown', '1.8.0'
 7 gem 'rack-jekyll', '0.4.1'                                                 
 8 gem 'rake', '10.4.2'                                                       
 9 gem 'puma', '2.12.2'
10 gem 'jekyll-tagging', '1.0.1'

jekyll-tagging is for tagging system. Check its repo for setting up tagging function in Jekyll.

2. Generate Gemfile.lock

1 bundle install

If any new gem package is added to the Gemfile, Gemfile.lock need to be regenerated.

3. Create for rack-jekyll

1 require 'rack/jekyll'                                                      
2 require 'yaml'                                                             
3 run

4. Create Rakefile

1 namespace :assets do                                                    
2   task :precompile do
3       puts `bundle exec jekyll build`
4   end
5 end                                                                        

5. Create Procfile for Heroku

1 web: bundle exec puma -t 8:32 -w 3 -p $PORT

Because Heroku automatically assign port number for the process, so we need to use its global variable $PORT.

Commit to Heroku server

Now, we could add the files to the git repo and push the changes to Heroku server :

1 git push heroku master