If you are thinking of hosting a blog on GitHub and like to use a custom domain for it then this blog post is for you. I will show you which services I used and which settings have worked for me.
To follow this tutorial you need to have access to:
- The nameservers of your domain.
- The settings page of your GitHub repository
In the following steps, I use the domain jwillmer.de
. You need to replace this domain with your own to get it to work.
Domain Hosting Website
Create the following DNS records for your website:
CNAME
namedwww
and valueYOUR-GITHUB-USERNAME.github.io
CNAME
namedjwillmer.de
and valueYOUR-GITHUB-USERNAME.github.io
A
namedjwillmer.de
and value192.30.252.153
A
namedjwillmer.de
and value192.30.252.154
Make sure that the A
record IP’s are still the same by visiting the GitHub page.
Cloudflare Domain Setup
The tutorial from Cloudflare: Create a Cloudflare account and add a website
Quick Setup
- Create a free account at Cloudflare
- Add your website to Cloudflare and follow the instructions
- Use the free Cloudflare plan
- After the domain setup you get domainserver names displayed. Copy them and replace your current at the website of your domain registrar
GitHub Setup
Detailed setup instructions from GitHub: Using a custom domain with GitHub Pages
Quick Setup
- Add a file with name
CNAME
to you root folder of the repository you like to host - Add your domain with
https://
in front as content of theCNAME
file:https://jwillmer.de
- Go to the repository settings page and locate the custom domain field. Add
jwillmer.de
in that field - If you use the static site generator Jekyll you need to set your domain and subdomain in the
_config.yml
:- Set
url
to your domain namehttps://jwillmer.de
- Optionally force SSL by adding
enforce_ssl: jwillmer.de
- Set
Cloudflare Modifications
- Go to the Crypto tab of your domain:
- Set the SSL option to
Full
- Set
Automatic SSL Rewrite
toOn
to fix http links (If this isOff
you need to useFlexible
as SSL option)
- Set the SSL option to
- Go to PageRules and create page rules for your website:
Discussion on GitHub
This tutorial was created after a request from Sampath Vanimisetti on Github. He helped me in the process to test this tutorial and improve it - thank you!