Jekyll and Git Repo Layout Ideas

  • @gridgiant

Jekyll and Git Repo Layout Ideas

06 May 2016

While it is common to talk about using Jekyll and Git together is is not always clear what is the best possible setup, I tend to use a few different setups depending on the situtaion.

Simple Static Sites

Simple single page, single editor static sites generally in my experience work well as a single repo containing both the jekyll files and the built site. Git can be used in this case for deployment with the web server serving the _site folder and also version management of the site for archival.

Single Editor

As sites become more complex the repo may need separating further. An obvious separation is to move the jekyll build folder into its own repo. This allows the site data and logic to be serpeate from the actual built site allowing for different targeted hosting soloutions. Such a method allows for easy deployment using git push with the repo contained within _site. Such a setup does however require that the content and jekyll logic repo ignore the _site folder. This is easily setup using the .gitignore file.

Multiple Editors

When mulitple editors of a site are anticipated my preferred approach is to split a typical Jekyll project into 3 repos.

  • the _site folder
  • the jekyll logic files
  • the content _posts and a pages folder (sometimes _data and _config)

Such a layout allows for different access to be granted to the different repos. The website publishing editor controls the _site repo and is responsible for pushing live site updates. Multiple branches can also be run from this repo allowing a development mirror site to exsits and of course there is an archive of the published material available.

The Jekyll repo is accessible to web developers who are not responsible for content but only the layout and the structure of the site.

The final repo contains the actual site content generally split into three folders _drafts, _posts and a pages folder.

The two final repos are set with post-receive git hooks as below,

#! /bin/sh

Some times the _data folder could be placed within the content repo and sometimes the _config may also be included within the content folder as well. However this is quite variable and depends on the exact user case.

Such separation when combined with a build server allows a jekyll static site to have its content managed by a user who only knows markdown and git push commands.