how to set up a custom domain on github

"Customize Your Presence: Setting Up a Custom Domain on GitHub"

By Richard Davis
AD

Elevate your GitHub presence by connecting with your audience through a custom domain. It not only enhances your profile's professionalism but also boosts your online identity. Here's a comprehensive guide on how to set up a custom domain on GitHub.

Before we delve into the steps, ensure you have a domain name registered with a domain registrar like Namecheap, Google Domains, or GoDaddy. If you haven't, sign up for one and choose your preferred domain name. Once you have your domain, let's proceed to connect it with your GitHub account.

Preparing Your Domain

To begin, you need to update your domain's DNS settings. This process varies slightly depending on your domain registrar. Here, we'll use Namecheap as an example.

AD
Set Up a Custom Domain for Your GitHub Pages
Set Up a Custom Domain for Your GitHub Pages
How to: Free Website Hosting + Custom Domain with Github Pages
How to: Free Website Hosting + Custom Domain with Github Pages
Set Up a Custom Domain for Your GitHub Pages
Set Up a Custom Domain for Your GitHub Pages

1. Log in to your Namecheap account and select your domain. From the 'Manage' tab, scroll down to the 'Advanced DNS' section. Add a new record with the following details:

  • Type: A
  • Host: You'll use the GitHub license plate for your repository, e.g., user.github.io for GitHub Pages or the specific subdomain you want, e.g., www
  • Value: 185.199.108.134 (This is GitHub's IP address.)

Verifying Domain Ownership

After adding the A record, you'll need to verify that you own the domain. GitHub requires this to ensure you're authorized to connect your domain. You can do this in two ways.

How To Get A Domain Name & Website For Free • Homely Economics
How To Get A Domain Name & Website For Free • Homely Economics
How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages

1. Using a TXT record: Add a new record with the following details:

  • Type: TXT
  • Host: Leave it blank or use '@' if necessary
  • Value: ghs.github.io

Or

AD

Uploading an HTML File

Alternatively, you can upload an HTML file containing a specific verification code to your domain. Here's how to do it:

1. Once you've added the A record, click on 'Verify' in your GitHub repository settings. GitHub will generate an HTML file and provide a URL containing a verification code.

2. Download the HTML file and upload it to the root directory of your custom domain using an FTP client or your domain registrar's file manager. Ensure the file is named CNAME.

AD

Connecting Your Domain to GitHub

Now that your domain is set up, let's connect it to your GitHub account.

1. In your GitHub repository, navigate to the 'Settings' tab. Scroll down to the 'GitHub Pages' section and select your branch (usually main or master). Click 'Save'.

If you're using a personal website, ensure you're in your user.github.io repository. If you're using a project or organization repository, you'll need to create a new repository with the name username.github.io (replace username with your GitHub username).

AD

Enabling Custom Domain for GitHub Pages

Now that your repository is set up for GitHub Pages, let's connect your custom domain.

1. In the 'Settings' tab, scroll down to the 'Custom domain' section. Enter your custom domain (e.g., example.com or www.example.com) in the text field and click 'Save'.

2. Once you've saved your custom domain, click on 'Verify' to confirm the connection. If the verification is successful, your custom domain should now be live.

Enabling Custom Domain for Other Repositories

If you want to connect a custom domain to another repository, follow these steps:

1. In the desired repository, go to the 'Settings' tab and scroll down to the 'Pages' section.

2. Click on 'Custom domain', enter your custom domain, and click 'Save'.

3. Verify the connection, and your custom domain should now be live for that specific repository.

Congratulations! You've successfully connected your custom domain to GitHub. Your online presence just got a boost, and you're now ready to impress your audience. Happy coding!

AD