Git & GitHub / GitHub Pages and Hosting

Setting Up Custom Domains for Pages

This tutorial will walk you through the process of setting up a custom domain for your GitHub Pages site. We will cover how to purchase a domain, configure your GitHub repository …

Tutorial 2 of 5 5 resources in this section

Section overview

5 resources

Covers deploying static websites using GitHub Pages.

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!

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Text Diff Checker

Compare two pieces of text to find differences.

Use tool

Image Converter

Convert between different image formats.

Use tool

PDF Splitter & Merger

Split, merge, or rearrange PDF files.

Use tool

Lorem Ipsum Generator

Generate placeholder text for web design and mockups.

Use tool

Random String Generator

Generate random alphanumeric strings for API keys or unique IDs.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help