Custom Domain for GitHub Pages Setup and Configuration

Author

Reads 985

Woman Looking at the Laptop with Adoption Website
Credit: pexels.com, Woman Looking at the Laptop with Adoption Website

Setting up a custom domain for GitHub Pages is a straightforward process that can be completed in just a few steps. To get started, you'll need to add a CNAME record to your DNS settings, which can be done through your domain registrar.

GitHub Pages supports custom domains from most popular registrars, including GoDaddy and Namecheap. You can verify your domain ownership through GitHub's Domain Verification process.

To configure your custom domain, you'll need to update your DNS settings to point to GitHub's servers. This will allow users to access your GitHub Pages site using your custom domain instead of a GitHub.io address.

Eligibility and Setup

GitHub Pages is available to users with public repositories, including those with GitHub Free and GitHub Free for organizations, as well as those with public and private repositories on GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

To use a custom domain with GitHub Pages, you'll need to have one of these plans. GitHub's plans page has more information if you're unsure which one you have.

The type of repository you have will also affect your ability to set up a custom domain. Public repositories are eligible for GitHub Pages, but private repositories require a paid plan.

Feature Eligibility

Shoper website opened on the computer
Credit: pexels.com, Shoper website opened on the computer

GitHub Pages is available to a wide range of users.

GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations.

You can also use GitHub Pages in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

For more information, you can check out GitHub's plans.

Introduction

Your app is complete and ready to be shown to the world, but you might want to change the default domain. You can choose a fully customized domain name to give customers or users a seamless experience.

To do this, you'll need to learn about the various types of domains supported by GitHub Pages. This will allow you to configure a custom domain on GitHub Pages.

You can optionally enforce HTTPS in your settings on GitHub, which is a good practice for security.

Setting Up a Custom Domain

To set up a custom domain for GitHub Pages, you'll need to follow these steps. First, set your domain in your GitHub project by going to the settings tab and adding your custom domain. This will create a file named CNAME in your repository, so be sure not to delete it.

Credit: youtube.com, How to Use a Custom Domain with GitHub Pages

You'll also need to set custom resource records for your domain. This involves adding A and CNAME records with specific IP addresses and URLs. For A records, use the IP addresses 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153.

To redirect your www subdomain to your original domain, add a CNAME record with your GitHub Pages profile URL, including a dot at the end. For example, if your GitHub username is YOUR-GITHUB-USERNAME, your CNAME record would be YOUR-GITHUB-USERNAME.github.io.

Apex domains require a slightly different setup. First, add your custom domain to your repository by clicking the settings tab and saving your custom domain. GitHub will automatically create a CNAME file at the root of your repository.

Next, visit your domain provider's dashboard and add an ALIAS or ANAME/A record pointing to your apex domain, using the IP addresses 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153.

Here's a summary of the IP addresses you'll need to use:

Note that it may take up to 24 hours for the changes to propagate, so be patient and try checking your domain again the next day if it's not working.

Domain Configuration

Credit: youtube.com, How to Host a Website on GitHub Pages Free (Custom Domain Setup Included)

To set up a custom domain for your GitHub Pages site, you'll need to follow these steps. First, set your domain in your GitHub project by creating a file named CNAME in the same repository.

You should not delete this file, as it's essential for the custom domain setup. Next, set a custom resource record for your domain with your domain name registrar. This involves setting A and CNAME records for your selected domain.

For the A record, you'll need to enter the IP addresses 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153. To redirect the www subdomain to the original domain, add a CNAME record with your GitHub Pages profile URL, ending with a dot (e.g., 'YOUR-GITHUB-USERNAME.github.io.').

To configure an apex domain, you'll need to visit your site's repository settings, type in your custom domain, and save it. GitHub will automatically create a commit with a CNAME file at the root of your repository.

On a similar theme: How to Host a Site on Github

Credit: youtube.com, How To Connect Custom Domain To GitHub Pages (Step By Step)

To add a custom domain to your repository, log into your GitHub account, select settings under your repository, and add your custom domain under the Custom domain section and click Save. A custom domain has now been added to your repository.

To add A records to point your domain to GitHub, create one A record for 192.30.252.153 and another A record for 192.30.252.154. Once these records have been created, allow at least 4-24 hours for the changes to propagate across the web.

Here are the IP addresses you'll need to enter for the A record:

  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153

Remember to replace 'YOUR-GITHUB-USERNAME' and 'your-domain.com' with your actual GitHub username and domain name.

Adding a Domain to GitHub

To add a custom domain to your GitHub Pages site, start by setting your domain in your GitHub project. This will create a file named CNAME in the repository, so don't delete it.

To set up your custom domain, you'll need to set A and CNAME records for your domain name register. For A records, use the IP addresses 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153. For a CNAME record, use your GitHub Pages profile URL with a .(dot) in the end, for example, 'YOUR-GITHUB-USERNAME.github.io.'

Credit: youtube.com, How To Connect GoDaddy Domain To GitHub Pages (Step By Step)

You can also use your domain provider's dashboard to add an ALIAS or ANAME/A record pointing to your apex domain to the IP addresses of GitHub Pages: 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153.

To add a custom domain to your repository, log into your GitHub account, select Settings under your repository, and add your custom domain under the Custom domain section and click Save. A custom domain has now been added to your repository.

Here are the IP addresses you'll need to use for free HTTPS support: 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153.

Configuring and Troubleshooting

To configure a custom domain for GitHub Pages, you'll need to link your domain to your GitHub repository. This can be done in the GitHub settings.

Make sure your domain is set up with a CNAME record that points to the GitHub Pages IP address, which is 192.30.252.153. You can check your DNS settings to verify this.

To troubleshoot common issues, check that your domain is correctly linked to your GitHub repository and that the CNAME record is set up correctly. If your site is still not showing up, try checking the GitHub Pages documentation for more information.

Worth a look: Website Page Ranking

Frequently Asked Questions

Is GitHub Pages domain free?

GitHub Pages is free for public repositories with GitHub Free and GitHub Free for organizations, but requires a paid plan for private repositories. Check your GitHub plan to see if GitHub Pages is included.

How to connect GitHub Pages to GoDaddy domain?

To connect GitHub Pages to your GoDaddy domain, set up a custom domain in your repository settings and configure DNS in GoDaddy by adding an A record. Verify your domain in GitHub to complete the setup.

Gilbert Deckow

Senior Writer

Gilbert Deckow is a seasoned writer with a knack for breaking down complex technical topics into engaging and accessible content. With a focus on the ever-evolving world of cloud computing, Gilbert has established himself as a go-to expert on Azure Storage Options and related topics. Gilbert's writing style is characterized by clarity, precision, and a dash of humor, making even the most intricate concepts feel approachable and enjoyable to read.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.