Site Updates


02-27-2016


Filed under: update

This update of blog site focuses on performance and security.

Originally I chose Github Page as hosting solution. Many Jekyll users do that partially following the suggestion from jekyllrb.org. The hosting on Github is free and there are rake receipes one can follow to easily set things up. There are however a few disadvantages.

The receipe suggests maining two git branches, one for editing and the other (master branch) for storing generated htmls. Github Page uses master branch to display the site. This forces a few limitations such as certain jekyll plugins cannot be used and more importantly, no support for https. Creative folks somewhat get around this by getting a cheap or free Cloudflare ssl plan and direct requests to Github page. This creates an insecure link between Cloudflare and Github Page. But at least end user will perceive the blog site as https-enabled. Github has always ignored developer requests of enabling https for Page.

The decision I have made is to finally move away from Github and self-host in DigitalOcean. Now I run nginx to front Jekyll with both http/2 and ssl enabled. Site no longer requires re-generating entire htmls locally and push the whole thing to server, a process that has become increasingly inefficient as number of pages grow. The deployment process has moved away from rake to a simple git push into a bare git repo created by git init --bare. Bare repos stores revision history without source files. Then a simple post-receive hook does all the rest:

root@wiki:~/blog-zlu/hooks (BARE:master)# cat post-receive

#!/bin/bash -l
GIT_REPO=$HOME/blog-zlu
TMP_GIT_CLONE=$HOME/tmp/blog-zlu
PUBLIC_WWW=/var/www/blog-zlu

git clone $GIT_REPO $TMP_GIT_CLONE
jekyll build --source $TMP_GIT_CLONE --destination $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit

I like this approach quite a bit. The deployment is much faster with git, without regenerating sites. Now the site is protected under ssl and it supports http/2. I will be able to use some much needed plugins in the future. I’ve left out deprecated redcarpet and pigment syntax highlighter in, at least for now.