↓ Featured

Hosting a Ghost Blog on GitHub Pages

I first began to use GitHub Pages to host my homepage in the start of 2018. I chose GitHub Pages, because it allows me to set the CNAME for my personal domain www.naut.ca to mirror the GitHub Pages domain yoonsikp.github.io, and it will happily serve pages over the new domain name. By placing a file in the root directory of the repository, GitHub handles all the redirects and correctly serves files.

My homepage was created entirely from scratch, and I used Jeremy Thomas's Web Design in 4 minutes to get a beautiful CSS theme up and running. Learning the basics of HTML5 and CSS3 was valuable, and I'm happy to have learned how to properly use the developer tools in most browsers (learning Javascript is for another time!).

Yesterday, I finally decided to take the time to get my blog functional. I've played around with Ghost in the past, and at one point last year I had set up a Ghost blog on a VPS with nginx serving as a caching proxy. Unfortunately I never got around to consistently blogging, and maintenance of the VPS was an honest pain. Knowing how unreliable I am with taking care of the VPS, I decided that going the static page route was the best choice. Enter Buster, a tool that converts an entire Ghost Blog into a folder for the web server of your choice.

I wrote a short script that when run, will convert the blog using Buster, and then push it to GitHub Pages. If you want to use this script, make sure to use SSH GitHub authentication, and make sure that the directory passed to Buster is a full path.

#!/usr/bin/env bash
python ~/buster/buster/buster.py generate --domain=blog.naut.ca --dir=/home/yoonsik/tmp/blog
cd ~/tmp/
git clone git@github.com:yoonsikp/yoonsikp.github.io.git
cd ~/tmp/yoonsikp.github.io/
git config user.name "yoonsikp"
git config user.email "park.yoonsik@icloud.com"
git rm -r ~/tmp/yoonsikp.github.io/blog
mv ~/tmp/blog ~/tmp/yoonsikp.github.io/
git add ~/tmp/yoonsikp.github.io/blog/*
git rm -f ~/tmp/yoonsikp.github.io/blog/robots.txt
git commit -m"$(date)"
git push origin master
cd ~/
rm -R -f ~/tmp/

The obvious benefits to hosting on Github Pages is the price (free) and the zero management required.

Unfortunately, Github Pages has a problem when serving secure content over a personal domain. Github Pages has an SSL certificate for domains that match *.github.io, but this certificate won't be accepted for my personal domain. In order to get HTTPS working on the blog, I enabled a Cloudflare proxy for just www.naut.ca. Cloudflare provides a trusted SSL certificate for my personal domain, and most importantly, has an option to ignore SSL certificate errors on the backend, i.e. the github.io only certificate error.
Update: May 3rd, 2018
Github now provides an SSL certificate for your custom domain. Now, Cloudflare acts only as my DNS nameserver.

Overall, my experience with GitHub Pages and Cloudflare has been stellar, and blog updates pushed to the repository only take a few minutes to become live.

About Yoonsik Park

Comments