How to get multiple domains pointing to GitHub Pages using Cloudflare

I recently created a one-man-company to do IT Infrastructure consulting (I even got some cute business cards!). The name of the company is Curious Elephant and as part of creating the company in Portugal I get free DNS ( and web hosting for a year. So I ditched the web hosting and wanted to simply point the company URL to this website.

What you can learn from this post

The naive approach

As you may or may not have noticed this is done using Jekyll and GitHub Pages. And it already has a custom domain name ( pointing to it.

Naively, I tried simply setting up a CNAME record for to and added the new domain in the CNAME file of the repo. It didn’t work.

The Cloudflare way

As I read on GitHub Pages help and on stackoverflow (where else?), the use case of multiple custom domains pointing to your github website simply is not implemented. One can create a second repo and push the same code to both repos and have a CNAME in each of the repos, but this sounds like a silly approach to me.

But there is DNS redirection magic offered by many domain registrars or name servers. Enter Cloudflare.

For clarity here are the relevant DNS records (the IPs are github’s IPs):

Record type Name Value

A quick search on their help area led to Page Rules, so I quickly created this:

Page Rule in CloudflarePage Rule in Cloudflare

After a minute or so I could type my new custom domain and come straight to this website.

BONUS: The rule is setup so that if I type in something like it seamlessly redirects to :)

I hope this helps!

If you find mistakes with these recipes, feel free to raise an issue here.

For a more detailed explanation on the DNS records and http > https redirection, check Andrew Molney’s post.