Using Nanoc to fill Github Pages

04 Jul 2012

Learning to use git to update GitHub Pages -- a free web server.

Started out with an already-existing nanoc folder.

I Installed git for mac using the standard installer supplied on (version and created an account on github.

Created a repository called

Followed (approximately) this link although I made a few changes.

First of all, I already had a checkin, so could skip the first code box. I did rename the master branch to source and add a second remote:

git branch -m master source
git remote add pages<user>/<user>
git push -u pages source

The output sounds promising:

Counting objects: 102, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (95/95), done.
Writing objects: 100% (102/102), 237.00 KiB, done.
Total 102 (delta 19), reused 0 (delta 0)
 * [new branch]      source -> source
Branch source set up to track remote branch source from pages.

The source branch now holds the entire page source (including any output).

Now I followed the cloning instructions quite rigidly (because I do not really understand them yet).

# fetch a working copy of your repository
  $ git clone<user>/<user> output
  $ cd output
# create the isolated branch
  $ git symbolic-ref HEAD refs/heads/master
  $ rm .git/index
  $ git clean -fdx

Then recreate the output files:

cd ..
nanoc compile
git commit -a
git push pages
cd output/
git add *
git commit
git push origin master

The git push origin master part was tricky to figure out to me. It pushes the output folder's content to it's set remote origin (which came from the clone, I assume. Adding the master determines that the files are going into the master branch (which is the leading branch for the GitHub Pages).

Finally, I did:

 touch .nojekyll
 git add .nojekyll
 git commit

 vi .gitignore       #add .nojekyll to this file

This should put a .nojekyll file into the repository, that will not get clobbered when I nuke the output/ folder (I hope).

So now, the workflow is:

  1. Update files in the content/ folder
  2. Compile and upload to test server (I use a rake file)
  3. Verify results
  4. In the source folder: git commit -a; git push pages
  5. In the output folder: git commit -a; git push origin master

TODO: Add a rakefile to auto-push both the source and the output once I have a satisfactory build.

Pushing using nanoc-git

I am playing with nanoc-git. I found it through a Google search. It's maker claims it to be alpha-level software. Let's see. It lives here.

The script does rebuild the output folder implicitly. So it breaks the prototyping build thing that I have described above. Maybe I'll try to rewrite it to allow some kind of prototyping, or maybe I will stick with the plan before. I will see. Good thing I'm keeping this blog, because I tend to forget each syntax before I get to use it again.

For sake of documentation, I did the following:

Then, to execute: `rake deploy:git' should

  1. Clean the nanoc site
  2. Check out the source (source) from git
  3. Compile the site using nanoc
  4. Check out the destination (master) from git
  5. Copy all the files from the output/ folder to the root of master
  6. Commit in git
  7. Push to the remote master
  8. Check the source back out

A possible workflow could be:

# Edit the file 
git add <file>
git commit 
rake co  #this is my prototyping (sitecopy) rake

# Check: ok?

rake deploy:git

or another option:

# Edit the file 
rake co  #this is my prototyping (sitecopy) rake

# Check: ok?

git add <file>
git commit 

rake deploy:git

Getting a domain name

I registered at and organized a free DNS service to do the DNS hosting. Then, tried to set up the CNAME following the documentation at Github.

git checkout master
# just one line: 

git add CNAME
git commit
git push pages
git checkout source

Did not work immediately, but many times DNS can take some time to update. Let's wait and see.