Hosting a site on GitHub Pages with custom domain and free SSL

Posted on

GitHub pages is a great place for hosting a static website. It’s easy to add a custom domain name too by pointing the domain name’s name servers to GitHub’s and add a CNAME file to the root of your site and you’re done. If you use a custom domain name though you can’t have the site served over HTTPS by default.

Cloudflare is a great CDN with a generous free-tier which offers free SSL. You can use it with GitHub pages and have your pages served over HTTPS.

  1. Sign up for an account at

  2. Add your domain name to Cloudflare

  3. From your domain registrars site change the nameservers of your domain name to point to Cloudflare

  4. Change the A records of your domain to point to GitHub, mine are * points to and points to

  5. Wait a short while - and you’re done!


Once you’re all setup there’s a range of settings and controls in the Cloudflare admin, and paid-upgrades to premium features available. I recommend setting the ‘Always use HTTPS’ and ‘Automatic HTTPS Rewrites’ options to On (crypto tab).

There are a couple of limitations to be aware of;

  • It’s technically not fully encrypted end-to-end. It’s Flexible SSL which means its encrypted from Cloudflare to the visitor, but not from GitHub to Cloudflare.
  • SSL cert will only work on and not (who needs www. in their URLS now anyway?)

You might also like