Did you know that you can navigate the posts by swiping left and right?

Configuring custom domains on Github Pages (Part 1)

31 Mar 2019 . Category: tutorial . Comments

How to configure Github Pages to use a custom domain with Cloudflare?

In this tutorial I will show you how to configure a domain with name.com and use in your Jekyll website with Cloudflare.

Steps

  1. Enter name.com and then, search for your domain:

  1. After your send your information, you’ll need to pay (you can pay with PayPal but you need a verified Paypal account):

  1. If everything is right, you should be prompted to this:

  1. Then, you’ll need to return to your Repository Settings:

  1. And write your custom domain (Note: the keyword www is required):

5.1. It’s required that you create a CNAME file in your site root with the domain you’ll manage:

In my case:

  • z3nth10n.net
  • www.zenth10n.net

But there is a Bash command to do that:

printf "<domain>\n<domain with www>" > CNAME && git add . && git commit -m "Added CNAME" && git push

Example:

printf "zenth10n.net\nwww.zenth10n.net" > CNAME && git add . && git commit -m "Added CNAME" && git push

  1. Now go to Cloudflare and register a new account:

  1. Cloudflare will request your domain name, simply Add it as shown below:

  1. By default this will be shown as this:

Here you need to press “Continue” button, we’ll configure this later.

  1. Cloudflare will need a new NS records in name.com:

  1. Go to your site Configuration > Nameservers, and remove then:

  1. You’ll need to apply changes in order to make this work:

  1. Then, just write them:

  1. If everything go well you’ll see this:

  1. Go to your _config.yml file and change all variables that depends on url:

  1. Return to Cloudflare, and point this Github IP: 192.30.252.153 (as an A record for the @ wildcard) and a CNAME record pointing to www as a alias to your site url (in my case: z3nth10n.github.com) in your Cloudflare dashboard:

  1. To check that everything went right, just use this command:
$ curl -sI "http://z3nth10n.net" | grep "HTTP/\|Location"

If you have problems in Windows, you can use:

ipconfig /flushdns

This will delete all your DNS cache, so if you have any issue and you fix it, your changes will apply quicklier.

  1. Enjoy!

Note: In case you have problems don’t hesistate to ask in a comment.

Best regards!