Search code examples
jekyllgithub-pages

Is there an easy way to make Jekyll output files to a docs/ directory?


I'm using Jekyll to build a Github pages site, and have run into a sort of silly issue.

Github recommends Jekyll for Github pages, so I sort of assumed it would just work; however, it does not.

Jekyll by default builds all files to the _site/ directory, which is really nice and looks fancy and so on, but is not an option for Github pages.

Github seems to offer only three options for hosting:

  1. Root of master Branch
  2. docs/ Folder of Master Branch
  3. gh-pages Branch

So, pray tell, why can I not build Jekyll to either A. a branch with a custom name or B. a folder named docs/ instead of _site?


Solution

  • Turns out I didn't read enough docs.

    The solution is to add a tag to the _config.yaml file in the root of the project.

    This line will switch from using _site to docs/ for build output:

    destination: docs/

    Alternately, you can pass this as an environmental variable like so:

    jekyll build --destination docs/