how to set up github using domain

How to Set Up GitHub with Your Domain

By William King
AD

Setting up GitHub using your own domain is a rewarding way to personalize your online presence and promote your projects. By following this guide, you'll learn how to connect your custom domain to GitHub Pages and make your projects stand out.

Before we dive in, ensure that you have a GitHub account, a custom domain, and have configured your nameservers (DNS) to point to GitHub's nameservers. If you haven't done this, you can follow GitHub's official guide on configuring a custom domain.

Enable GitHub Pages for Your Repository

Begin by enabling GitHub Pages for your repository. This will create a website for your project using the existing content in the master branch.

AD
How to Get Started With GitHub in 2026 and Build Real Projects Fast
How to Get Started With GitHub in 2026 and Build Real Projects Fast
How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages
Set Up a Custom Domain for Your GitHub Pages
Set Up a Custom Domain for Your GitHub Pages

To enable GitHub Pages, follow these steps:

  • Navigate to your repository
  • Click the "+" icon on the top bar and select "New File" or "Create new file" from the dropdown menu
  • Name the file index.md (without the quotes), and enter the following content: # Hello World!
  • Click "Commit new file" at the bottom of the page
  • Now, go to your repository's settings by clicking the gear icon on the top right corner, then select "Pages" from the left sidebar
  • Under "Source", select main (or master, if that's your default branch) and click "Save"

Verify Your GitHub Pages Site

Your GitHub Pages site should now be live. To verify this, visit http(s)://yourusername.github.io/your-repo-name in your web browser. Replace yourusername and your-repo-name with your GitHub username and repository name respectively.

How To add a Custom Domain On Github Pages
How To add a Custom Domain On Github Pages
GitHub Basics Tutorial - How to Use GitHub
GitHub Basics Tutorial - How to Use GitHub

You should see the "Hello World!" heading on the page. If you don't, double-check that you've followed all the steps correctly and that your repository is public.

Configure Your Custom Domain with GitHub Pages

Now that GitHub Pages is enabled for your repository, let's configure your custom domain to point to your GitHub Pages site.

AD
  1. In your repository's settings, click on "Pages" again
  2. Scroll down to the "Custom domain" section and enter your custom domain (e.g., example.com)
  3. Optionally, you can add a www subdomain by enabling the "Enforce HTTPS" checkbox
  4. Click "Save". It may take a few minutes for the changes to take effect

Create a CNAME File for Your Custom Domain

To ensure that your custom domain works correctly, you need to create a CNAME file in your repository.

Follow these steps to create a CNAME file:

  • Go to your repository and create a new file named CNAME (all caps)
  • Enter your custom domain (e.g., example.com) without any leading "www" or trailing period
  • Click "Commit new file" at the bottom of the page

Verify Your Custom Domain

Visit your custom domain (e.g., http://example.com) in your web browser. You should now see your GitHub Pages site!

AD

If you configured a www subdomain, try visiting http://www.example.com as well. Ensure that it redirects to your primary domain.

Congratulations! You've successfully set up GitHub using your custom domain. As a final step, you may want to configure a custom 404 page or add a favicon to make your GitHub Pages site truly unique. Happy coding!

AD