May 6, 2015

Setting up a Jekyll Blog on a Github Pages Subdirectory

Like many others, we at Codedge host our organization's website through Github.

Setting up a Jekyll Blog on a Github Pages Subdirectory

Like many others, we at Codedge host our organization's website through
Github. Also like many, we wanted a development blog as well, but it creates interesting challenges when you need to host both at the same time. Simply placing all of the Jekyll files in a blog subdirectory leads to that dreaded email from Github immediately after your push:

"The page build failed with the following error"

But why?

The Solution

Looking through the Jekyll documentation, it turns out Github overrides source in _config.yml, which defines the top-level directory. Anything defined in a subdirectory is simply ignored, and there is absolutely no way around this.

So what to do? Make a new repository containing just the Jekyll files in the
top-level directory. This blog will be treated as a "project" website instead of an organization website, so remember to put everything on the gh-pages branch. Make sure in your _config.yml that baseurl is configured to /blog (or any other subdirectory of your choosing). Also, if you are using a custom domain, don't forget to copy the CNAME file from the original organization repository.

If everything pushes correctly, both your website and your blog should be
running concurrently!