Skip to content

Setting up Github Pages With custom domain over HTTPS#

With Github pages, we can create our blogs in our own domain over HTTPS completely free. Of course you should pay for your domain name at the Registrar.

Create Github pages on

  1. On Github create a repo with name :
  2. Push a file index.html to branch master or gh-pages
  3. Now you can access your github page by going to

From now on, you've created a fully operational blog on, you can also enable HTTPS on it by going to the repo's settings menu, everything is free.

If you dont need to use a custom domain like, you can stop here, but if you want it, please go ahead.

Register a custom domain#

Register a custom domain on your preferred domain name registrar

Setup DNS on DNS registrar#

  1. Add subdomain

  • Add a CNAME DNS record pointing www to
  • Add a CNAME DNS record pointing blog to

  • Add APEX domain

My DNS registrar doesn't support ALIAS nor ANAME, I should go with the A records :

- Add a **A** DNS record pointing **@** to ****
- Add a **A** DNS record pointing **@** to ****
- Add a **A** DNS record pointing **@** to ****
- Add a **A** DNS record pointing **@** to ****

Enable custom domain on

  1. Go to github repo

  1. Add your custom domain in : Settings -> Options -> GitHub Pages -> Custom domain
  2. If you'll just run a blog on your domain, I suggest to use APEX domain name here instead of subdomain, for example:
  3. This step creates implicitly a file named CNAME under the root of your git repo, the content of the file CNAME is just your custom domain.
  4. The commit message is 'Create CNAME'
  5. On the same page, the option Enable HTTPS serves to redirect HTTP traffic to HTTPS. The option is grayed out for the moment, because initially is binded with a github's certificate so as to In order to secure correctly your new site, Github needs to ask LetsEncrypt to issue a new certificate where the CN is, than when people visit your web site, they will see a green padlock in the address bar. The generation of LetsEncryt certificate takes usually 1 or 2 days, be patient, once you see a green lock when you open, you can come back here and enable the option Enable HTTPS.

Enable HTTPS for custom domain with Cloudflare#

This solution is partially deprecated as Github supports natively HTTPS for custom domains now, but Github pages doesn't provide the wildcard certificate yet. For a better compatibility, Cloudflare HTTPS solution is still one of the best choices.

Some tutorials : tutorial 1 , tutorial 2

Simplified steps :

  1. Sign up for a free Cloudflare Account
  2. Follow the wizard, give your custom domain, Cloudflare should find all your CNAME and A records.
  3. Cloudflare should ask you to change your custom domain's default DNS servers given by your DNS registrar to the Cloudflare ones.
    • The change may take several hours to take effect
    • Cloudflare DNS example:,
  4. Go to Crypto tab, verify SSL is set to Full
  5. Go to Page Rules tab, add a page rule : with Always Use HTTPS

If everything goes well, you can access your custom domain by HTTPS. And if you verify the HTTPS certificate, it should be signed by COMODO, the certificate's CN is a server and one of the SAN is your custom domain.

Enable HTTPS for custom domain With Github#

Github announced very recently (on May 01, 2018) the support of HTTPS for custom domains, this is really a great feature. After the test, I found that the HTTPS certificate is signed by where the CN is your's CNAME, and everything is free. Thx Github and LetsEncrypt !

You can also enable the HTTP to HTTPS automatic redirection from here.

If you use subdomain (for ex:, hereunder the HTTPS tests :

With Cloudflare's HTTPS solution, there's no such error, as Cloudflare signed a wildcard certificate to * in the SAN.

If you use APEX domain (for ex:, hereunder the HTTPS tests : - typed, redirected to - typed, redirected to - typed, redirected - typed, redirected to

With APEX domain, everything is good on HTTPS with native Github solution, you dont need Cloudflare