GitHub Pages with a Custom Domain
My website used to be hosted on GitHub Pages. When it came to hooking up my domain, I found the instructions a little confusing in places. So here’s what worked for me…
Step 1 of 5
If you haven’t already done so, setup a GitHub account and buy a domain from your preferred domain name registrar.
Step 2 of 5
Follow the instructions to setup GitHub Pages. This is fairly straight forward:
- Create a new repository called [your-github-username].github.io
- Clone the repository and create an index page
- Push to GitHub.
Your new site will be live at [your-github-username].github.io
Step 3 of 5
Go to your new GitHub Pages repository settings, and add your domain:
Step 4 of 5
Go to the DNS settings of your domain and add/amend the following two A Records:
192.30.252.153 192.30.252.154
… and a CNAME for the apex (www) pointing to:
[your-github-username].github.io
When you’re done it should look something like this:
Bear in mind that DNS settings can take some time to propagate.
Step 5 of 5
Add a CNAME file to your website’s root folder:
- Create a new .txt file using your preferred text editor software.
- Add just your domain as the content. For example:
www.davidhughes.co
- Save the file as CNAME.txt
- Add this to your website’s root folder, and push the change to GitHub.
Now, when you visit your domain, this should point to your GitHub Pages index file.
I hope you find this Tutorial helpful. If you're having any problem, I would be happy to help. You can leave a comment below, send me a message on Twitter or use the contact form here.