06 April 2015

This post explains the steps to publish your blog using JBake and deploy it to GitHub Pages.

Install JBake
  • Download it from http://www.jbake.org

  • Unzip it somewhere:

    $ unzip ~/Downloads/jbake-2.3.2-bin.zip
    $ cd ~/jbake-2.3.2/
    $ export PATH=~/jbake-2.3.2/bin:$PATH
Install Java, Maven and Git in Fedora 21/22:
$ sudo yum install -y java-1.8.0-openjdk-devel maven git

Edit ~/.m2/settings.xml to add a <server>:

      <id>github</id> (1)
      <password>shequeethaich9eegaht2tahch4ooviephaqu0di</password> (2)
  1. The server name

  2. The OAUTH Token from github.com

Paste the OAUTH you get from github.com Applications page.

Create a project in GitHub, call it "username.github.io" and clone it:

$ mkdir ~/src
$ cd ~/src
$ git clone git@github.com:rarguello/rarguello.github.io.git

Create a test page just to see if it works:

$ cd ~/src/rarguello.github.io
$ echo "Hello" > index.html
$ git add index.html
$ git commit -m "Test page"
$ git push

Check http://rarguello.github.io to see if it says "Hello".

Create a new branch called "jbake" to add the blog source code:

$ git checkout --orphan -b jbake
$ mkdir -p src/main/jbake
$ cd src/main/jbake
$ jbake -i
  JBake v2.3.2 (2014-09-21 01:47:44AM) [http://jbake.org]
  Base folder structure successfully created.
$ cd ~/src/rarguello.github.io
In your DNS server add a CNAME to www.ricardoarguello.com and ricardoarguello.com pointing to rarguello.github.io.
Add a CNAME in JBake "assets" diretory
$ echo www.ricardoarguello.com > ~/src/rarguello.github.io/src/main/jbake/assets/CNAME
Add a .gitignore to the "assets" directory:
$ echo target > ~/src/rarguello.github.io/src/main/jbake/assets/.gitignore

Edit ~/src/rarguello.github.io/src/main/jbake/jbake.properties to your taste


Create a pom.xml file to bake the site:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <name>rarguello.github.io website</name>
  <description>The rarguello.github.io website source code</description>
          <message>Site update</message>

Bake the site:

$ mvn package

If your like it publish it using the "site" Maven goal, that deploys the baked HTML site to the "master" branch, that you can access using http://username.github.io/

$ mvn site

To have Travis build deploy the website automatically, you have to encrypt your GitHub Token. Create a .travis.yml file:

language: java
  - openjdk7
  - mvn --settings src/travis/settings.xml clean package site
  - jbake

Then, add the encrypted GitHub Token to the file:

$ sudo yum install -y ruby rubygems
$ travis encrypt GH_TOKEN=<token> --add env.global

You also need a custom Maven settings.xml file:

$ mkdir -p src/travis
$ vi src/travis/settings.xml

Push the changes:

$ git commit -a -m "Add Travis support"
$ git push

Travis will deploy your site on every commit on the "jbake" branch.