Thoughts of Geoff

Some writing by Geoff Petrie

Adding a CNAME to Your Octopress Blog

This option isn’t terribly well explained in the Octopress documentation, and slightly confusing within the Github.

So that I could get blog.geoffpetrie.com to work as my url to my Octopress blog hosted by Github at geopet.github.com, I needed to go to my current hosting service. In my case this is currently Dreamhost.

Since I wasn’t changing my top-level domain (TLD), I wanted to keep geoffpetrie.com pointed at my hosting service, I wanted to add a subdomain, i.e., blog to my domain name server (DNS) run by Dreamhost.

I went into the DNS configuration in the Dreamhost cpanel and added blog as the name/record, CNAME as the type and geopet.github.com as the value.

This is the first step, and once the DNS is refreshed your new subdomain (in my case blog.geoffpetrie.com) will start pointing to a Github 404.

The next step is to add the CNAME to your Octopress master branch. This is surprisingly simple, but not completely intuitive. In the top level of the source branch, you want to use the command:

echo 'blog.geoffpetrie.com' >> source/CNAME

Of course you’re going to use your own subdomain instead of blog.geoffpetrie.com. This command will create the CNAME file in your source directory with the url that you want to direct people to.

After this all that’s needed is rake generate and rake deploy. (You may as well commit to your source branch after this.)

Wait a couple of minutes for things to work their way through DNS and Github’s world and you’ll be looking at your Octopress blog on your own domain.