Using a custom domain name can be important for personal marketing and offers one greater freedom to in choosing their domain representation (GitHub Pages requires the domain name <your_domain>

Purchasing a domain name


  1. Go to and purchase whatever domain you want ($12 / year usually).

  2. Create a file called CNAME in the main directory of your github repo. Add the lines <your_domain> and www.<your_domain> (e.g. and

  3. Open up the DNS settings for your site on

  4. Under “Name servers”, click “Use the Google Domains name servers”.

  5. Under “Custom resource records”, create the following records:

    • @, A, 1h,, (click the + button), (click the + button), (click the + button)
    • www, CNAME, 1h, https://<your_username><your_domain_name>. These records tell Google’s DNS to point to GitHub to find your page.

Securing your site with HTTPS


By default, github pages doesn’t support access to your site with HTTPS with a custom domain. This means that whenever someone clicks on your site after a google search, they’ll see a warning saying your site might be trying to steal your data. We don’t want this!

  1. Set up a free cloudflare account here: and add your website to your account.

  2. Under the DNS settings for your site on Cloudflare, go to “DNS Records”.

  3. Set up the following DNS Records:
    • A, <your_domain_name>,, Automatic TTL
    • A, <your_domain_name>,, Automatic TTL
    • A, <your_domain_name>,, Automatic TTL
    • A, <your_domain_name>,, Automatic TTL
    • CNAME, www, <your_domain_name>

    Note: <your_domain_name> should be like, NOT nor

  4. Scroll down to Cloudflare Nameservers and take note of the two nameservers provided to you.
    • Some examples are and
  5. Under the Crypto settings for your site on Cloudflare, scroll to “SSL” and ensure that Full SSL encryption is being used.

  6. Scroll to “Always use HTTPS” and flick the switch to “On”.

  7. Go back to the DNS settings at and go to “Name servers”.

  8. Click “Use custom name servers” and input the two name servers provided to you by Cloudflare.