custom domain site hosted on github

May 10, 2014

This website is hosted on github. It’s free, fast and reliable. You can only host static websites on github, but that’s not an issue if you use static site generator like Jekyll, or if you, like me, prefer using Haskell, there’s Jekyll’s good twin Hakyll.

To redirect your custom domain to the github page, you need to lookup the DNS for A Record IP, using either dig command or online DNS lookup tool. Then use the IP address you found to create A Record for your domain. Consult the github documentation if you need more details.

To redirect the github page to your custom domain create a CNAME file in the github pages repo and put your domain name in it (e.g.

It is handy to create a one-click publish shell script. Here is mine:


# Create _publish directory if it doesn't exits
mkdir -p _publish
cd _publish

# Clone the giuthub page repo or pull the latest version
if [ ! -d "" ]; then
    git clone
    git pull origin master


# Prepend the file names you want to keep in here with dot

# Clean up
rm -rf *

# Undo the name changes

# Hakyll by default generates site into _site directory
cp -rf ../../_site/* .

# Add all files to git
git add --all :/
git add -u :/

echo -n "enter commit message: "
read msg
git commit -m "$msg"

# If you are using cygwin, git push command will get stuck, so use the following command first to cofigure git to ask for password in a popup window
# git config --global core.askpass "git-gui--askpass"

git push origin master
comments powered by Disqus