Setting Up Custom Domains for Pages

Tutorial 2 of 5

Introduction

In this tutorial, we will guide you through the process of setting up a custom domain for your GitHub Pages site. By the end of this tutorial, you will be able to purchase a domain, configure your GitHub repository to use your custom domain, and verify your domain with your DNS provider.

Prerequisites:
- Basic knowledge of GitHub
- Basic understanding of DNS (Domain Name System)

Step-by-Step Guide

Purchasing a Domain

  1. You can purchase a domain from any domain registrar of your choice such as GoDaddy, Google Domains, Namecheap etc.
  2. Follow their specific instructions to purchase the domain.

Configuring Your GitHub Repository

  1. Navigate to your GitHub repository and click on Settings.
  2. Scroll down to the GitHub Pages section.
  3. In the Custom domain box, type the name of your newly purchased domain and click Save.

Verifying Your Domain with Your DNS Provider

  1. Go to your domain registrar's website and sign in.
  2. Navigate to your domain's DNS records.
  3. Add a CNAME record for www that points to YOUR-USERNAME.github.io, replacing YOUR-USERNAME with your actual GitHub username.
  4. Add four A records that point to the following IPs:
  5. 185.199.108.153
  6. 185.199.109.153
  7. 185.199.110.153
  8. 185.199.111.153

Code Examples

Example of a CNAME Record

www   3600   IN   CNAME   YOUR-USERNAME.github.io.
  • www: the subdomain for which the record is valid.
  • 3600: the time (in seconds) that the record is cached by DNS resolvers.
  • IN: signifies that this is an Internet record.
  • CNAME: the type of DNS record.
  • YOUR-USERNAME.github.io: the domain the record points to.

Example of an A Record

@   3600   IN   A   185.199.108.153
  • @: signifies that this is the record for the root domain.
  • 3600: the time (in seconds) that the record is cached by DNS resolvers.
  • IN: signifies that this is an Internet record.
  • A: the type of DNS record.
  • 185.199.108.153: the IP address the record points to.

Summary

In this tutorial, we've covered how to purchase a domain, how to configure your GitHub repository to use your custom domain, and how to verify your domain with your DNS provider.

For further learning, it would be beneficial to understand more about DNS and how it helps in the process of domain name resolution.

Practice Exercises

  1. Purchase a domain and create a simple GitHub pages website.
  2. Point your domain to your GitHub pages website.
  3. Verify if your domain is correctly pointed to your GitHub pages website.

Remember to continually practice your skills and explore different aspects of web development. Happy coding!