Hosting Your Site On Github

Github will host your site for free, which is incredibly nice of them. But for our purposes, there are some things to consider around how the repo is named:

Generally, given a repo named amazingrepo, if you push your Jekyll site onto a branch called gh-pages, the content will appear under http://username.github.io/amazingrepo/ (which is what you want for project-specific Jekyll sites); however there are some names that Github considers special and which are subject to different rules: if the Github repo is named like username.github.io, or, within a Github organisation, organisationname.github.io, then Github will attempt to Jekylify whatever it finds in master and the content will appear under http://username.github.io/ - that’s why this particular repo is named rawfunkmaharishi.github.io. For the purposes of this document, I’m going to assume that you have a Github organisation for your band called bandname and your repo is called bandname.github.io (and that you have control of the bandname.com domain). Does that all make sense?

So anyway, presuming you have some committed content, go create a Github repo with the appropriate name, then bring that remote in:

git remote add origin [email protected]:bandname/bandname.github.io.git

and push to it

git push origin master

then point your browser at http://bandname.github.io/ and you should see either Hello from Jekyll once again, or a 404 with a message about It may take up to ten minutes until your page is available. In this case, go make some tea or something.

CNAME

So you have some content hosted, for free, on Github, at http://bandname.github.io/. But wouldn’t it be nice if it was at http://bandname.com instead? Well that’s super-easy, too. You need a CNAME file at the root of the project (and note that you can only have the one CNAME, so you can’t have bandname.com and www.bandname.com, but it’s 2014 and it’s probably time we got past that):

echo bandname.com > CNAME

Then you need to configure your DNS: until about two weeks ago I’d have told you to create an A record pointing the root domain at this Github IP address: 185.31.18.133, but then I discovered that CloudFlare have some advanced voodoo they call CNAME Flattening which means that a root domain can be properly CNAMEd without breaking all your MX records, and now I don’t know what to think. You should probably take a look, it’s amazing.

So after committing, pushing, and waiting the requisite DNS-propagation-time (which seems to getting shorter and shorter, maybe it’s just me, get off my lawn), your amazing site will be available at http://bandname.com.