
To set up a custom domain with GitHub Pages and a GoDaddy domain name, you'll first need to verify ownership of your domain. This involves creating a CNAME record in your GoDaddy account.
GoDaddy offers a free DNS management tool that makes it easy to set up the necessary records. You can find this tool in your GoDaddy account under the "DNS" section.
The CNAME record points your domain to the GitHub Pages server, which is the gh-pages.net domain. GitHub requires this record to be set up in order to use a custom domain.
Suggestion: Godaddy Web Page Editor
Setting Up Custom Domain
To set up a custom domain, you'll need to buy a domain of your choice. Google domains are often considered the best in the market, but I went with GoDaddy due to their discount price.
The domain I chose is webrachna.in, which will be connected to GitHub pages in subsequent steps. You can choose any domain that suits your needs.
To set up the custom domain, you'll need to add a CNAME record for the www subdomain. This is recommended for a more professional look.
Add a CNAME record with the following details:
After setting up the DNS records, your custom domain should be up and running.
Verifying and Troubleshooting
Verify your custom domain by visiting www.customdomain.com and username.github.io to ensure it points properly to your GitHub Pages site.
DNS changes may take up to 24 hours to propagate, so be patient. To check whether the DNS is propagated successfully, use free online tools like DNS Checker or What's My DNS.
Once DNS propagation is complete, make sure the "Enforce HTTPS" option is checked in your GitHub repository's Pages settings. This will ensure a secure connection (lock icon) when visiting your custom domain.
Common issues with custom domains include redirects not working properly and assets not loading (CSS, images, etc.). To fix redirects, ensure both the apex domain and the www subdomain are properly configured in your DNS settings.
To troubleshoot assets not loading, ensure all asset paths in your HTML are correct for the domain. If you were using relative paths that worked on username.github.io/repository but don't work on your custom domain, you'll need to update them.
Here are some common issues and their solutions:
Connecting Domain to GitHub Pages
Connecting your custom domain to GitHub Pages is a straightforward process. You can buy your domain from a registrar like GoDaddy, which I chose for its discount price on the domain of my choice, webrachna.in.
To connect your domain to GitHub Pages, you'll need to create a map that tells the internet where to direct users who type in your domain. This is done through DNS (Domain Name System) records, which are like the internet's phonebook, translating human-friendly domain names into computer-friendly IP addresses.
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files from a repository on GitHub and publishes a website. By connecting your custom domain, you're essentially creating a redirect from your domain to your GitHub Pages website.
There are several ways to configure this connection, each with its own advantages. Here are some common methods:
- Using an A record to point to GitHub's IP addresses
- Using a CNAME record to create an alias from your domain to your GitHub Pages domain
- Setting up a subdomain (like sub.mydomain.com) vs. an apex domain (like mydomain.com)
- Configuring both www and non-www versions to work seamlessly
Understanding these options can help you choose the best approach for your custom domain and GitHub Pages setup.
Configuring Custom Domain
To configure a custom domain with GitHub Pages, you need to create a CNAME file in your repository. This file should contain your custom domain name.
First, add a CNAME file to your repository with your custom domain name. This will redirect visitors from your username.github.io site to your custom domain.
For example, if your custom domain is example.com, your CNAME file should contain the name "example.com".
You can also use the automatic method to create a CNAME file. Go to your site's repository on GitHub, click on Settings - Pages, and save your domain name in the "Custom domain" section. This will automatically add a CNAME file to the root of your source branch.
On a similar theme: I Own a Domain Name How to Create Website Free
To set up a CNAME record, you need to add a record to your DNS zone file. This record should point to your username.github.io GitHub Pages site.
Here's a table of the DNS records you should have when done:
If you want to set up a CNAME record for a www subdomain, you'll need to add a CNAME record with the following details: Host/Name should be "www", Value should be your-username.github.io, and TTL should be 600 seconds.
Setting up CNAME records should not take time to propagate its changes, and you should be immediately ready to verify your changes.
Conclusion and Final Steps
Connecting your GoDaddy domain to GitHub Pages is a great way to get a professional web presence. This setup is cost-effective and puts you in complete control.
Remember to periodically check that your HTTPS certificate is valid, as this connection isn't a set-it-and-forget-it task. GitHub occasionally updates its IP addresses, so staying subscribed to GitHub's engineering blog is a good idea for anyone managing multiple sites.
Your custom GoDaddy domain with GitHub Pages hosting is perfect for showcasing your portfolio, documenting a project, or launching a business website.
Featured Images: pexels.com


