How to set HTTPS on GitHub Pages with a custom domain for free

Default featured post

How  to set HTTPS on GitHub Pages with a custom domain for free. GitHub Pages is a convenient and easy way to set a simple static site up quickly. It’s very suitable for those who prefer Markdown over HTML, thanks to Jekyll. Sites hosted on GitHub Pages almost need no maintenance. Hence, content creators do not need to waste their time on maintenance and instead can focus on writing. On top of all, GitHub Pages is free and comes with a free [username].github.io.

GitHub Pages allows users to configure their own domain by adding a CNAME file that contains the desired URL. The file should be presented in the repository and the user must add CNAME in his DNS setting that points to [username].github.io URL.

Until here everything is alright but what if someone wants to have his custom domain that is pointing to GitHub Pages run on HTTPS. There is no straightforward solution to accomplish such a thing because GitHub Pages only supports SSL for the github.io domain, not for custom domains.

The only way to have HTTPS on a custom domain hosted on GitHub pages is to use Cloudflare.

To do so, first just add your custom domain to the Cloudflare like this:

After that go to the DNS section and create a CNAME with the domain/subdomain that you want to be pointed to GitHub pages, like below.And make sure that the traffic passes through Cloudflare, see the highlighted section in the above picture.

The last step is to go to PageRules and create a new rule like this picture.Mind the * at the end of the URL.

That is all. You just need to wait maximum 24 hours until the changes to take effect.

Enjoy running your site securely on GitHub Pages.