[Notes] Setup Jekyll Harmony Theme on GitHub

[!!] Now I have moved my blog back to Octopress with CleanPress theme. However the last two days playing with Harmony pushed me to get a further understanding about github, github pages and jekyll.


I am using the Jekyll theme: Harmony

If you are new to github/git, the following link is highly recommanded to check first: Learn git in 15 mins

If you want to try it on your local system, you probably will be asked to install the latest Ruby. Because Jekyll requires Ruby 2.0.0 or above, you can install RVM in following commands (in this case I use Kali Linux, step this if you are using Kali 2):

# install RVM mpapis public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# download and install RVM stable with latest ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
# after installed, to start using RVM
source /usr/local/rvm/scripts/rvm
# check current ruby version
ruby --version

Set up jerkll theme on local system (Kali Linux):

  1. Create a Repo on github (Note: In order to use Free github page domain, this Repo must use your github username as the repo name: f4l13n5n0w.github.io in my case

  2. run the following commands in my Kali linux:

cd /opt
# download Jekyll theme on my local system
git clone https://github.com/gayanvirajith/harmony.git
cd harmony
# install bundler
gem install bundler
# install dependencies by using bundle
bundle install
# set it up on local, will listen on http://127.0.0.1:4000
jekyll serve

You might get the following error when run jekyll serve.

root@kali:/opt/harmony# jekyll serve
/usr/local/rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /usr/local/rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/coffee-script-2.4.1/lib/coffee_script.rb:1:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/coffee-script-2.4.1/lib/coffee_script.rb:1:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/coffee-script-2.4.1/lib/coffee-script.rb:1:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/coffee-script-2.4.1/lib/coffee-script.rb:1:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-coffeescript-1.0.1/lib/jekyll-coffeescript.rb:2:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-coffeescript-1.0.1/lib/jekyll-coffeescript.rb:2:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/lib/jekyll/deprecator.rb:46:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/lib/jekyll/deprecator.rb:46:in `block in gracefully_require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/lib/jekyll/deprecator.rb:44:in `each'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/lib/jekyll/deprecator.rb:44:in `gracefully_require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/lib/jekyll.rb:141:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/bin/jekyll:6:in `require'
    from /usr/local/rvm/gems/ruby-2.2.1/gems/jekyll-2.4.0/bin/jekyll:6:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.1/bin/jekyll:23:in `load'
    from /usr/local/rvm/gems/ruby-2.2.1/bin/jekyll:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

In order to fix it up, you need to insert gem 'therubyracer' into the file Gemfile as follow and run bundle install again (Note: github-page server do not have this problem):

1
2
3
4
5
6
7
8
9
source 'https://rubygems.org'

require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)

gem 'therubyracer'
gem 'github-pages', versions['github-pages']
gem 'rake'

If everything is good, after run jekyll serve, you will be able to access your blog on http://127.0.0.1:4000

Next important thing is to modify the configuration file _config.yml.

The paramters baseurl and url have to be set correctly in order to make your site works

Note: If you are going to set the blog under the root directory, you have to set baseurl to or '' as follow (DO NOT set it to ‘/’):

# Base URL
baseurl: 

# Site live URL
# url: http://f4l13n5n0w.github.io

# Localhost 
url: http://127.0.0.1:4000  

Set url to http://127.0.0.1:4000 when developing locally and DO NOT forget to change it back to your github page’s link (in my case is http://f4l13n5n0w.github.io)

Update your site to github

After you customized your blog locally, using the following code to publish it to github.

cd /opt/harmony
rm -rf _site
cd /opt
# git clone my blog Repo on my local system
git clone https://github.com/F4l13n5n0w/F4l13n5n0w.github.io.git
cd F4l13n5n0w.github.io
# copy all the files from Jekyll theme to my blog repo
cp -rf ../harmony/* ./
git add --all
git commit -m 'Initial website'
# push it back to github, now wait couple of seconds or even minutes, you will find your blog already up from the github.io link (in my case: http://f4l13n5n0w.github.io)
git push origin master

Further reading

Special Thanks

After two nights scratching hair and friends' help, I finally got my blog back with refresh theme!

Anthony Ferrillo Bumped into his blog when I was checking new challenges on VulnHub, then I make myself incorrigible to upgrade my blog to the new beautiful theme. T.T

Gayan Virajith The coder of the Harmony theme, whom is very patient and helpful. Very nice and tidy theme, great job~

Special Thanks to you guys for your time and quick reply when I got stuck in setting this up, help and guide me to put it through. All great people and nice to chat with you~

2015-10-03 07:05:12 -0400