Jekyll and Github: optimal setup
Apr 9, 2018
2 minute read

As I already mentioned in my other post, you can very easily pass the limitations Github Pages poses you by building the site locally and pushing only the static files.

If you don’t know anything about jekyll, I recommend to first read the docs.

So then you have two choices:

  1. Pass the source files of your site to the master branch
  2. Pass the files to the /docs folder of the master branch

My choice is to use the /docs folder as the build place. This way I don’t need to switch and merge branches and my workflow is easier.

Usually, I build the site for local preview using bundle exec jekyll liveserve --drafts. --drafts shows drafts along posts. liveserve command automatically refreshes the page when some file was changed, possible when using this plugin.

When building for publishing I use JEKYLL_ENV=production bundle exec jekyll build -d 'docs'. The environment variable is for Google Analytics. -d is for output destination.

To make it easier I have included this two aliases in my .bashrc file:

alias release="JEKYLL_ENV=production bundle exec jekyll build -d 'docs'"
alias devel="bundle exec jekyll liveserve --drafts"

Also, I use this plugin to make it easier to create and manage drafts and posts.

My usual workflow is:

  1. bundle exec jekyll draft "Your article title here"
  2. Write the post
  3. bundle exec jekyll publish "Path to your draft here"

As you can see, the create, edit, publish cycle is way easier with the above plugin.

As for now, this setup works best for me.



comments powered by Disqus