How to set up a Bluehost subdomain for a GitHub pages site
I already have a personal website with a page about my previous research, so I decided to point my open research GitHub pages to a subdomain there rather than use the default GitHub pages url gemmadanks.github.io. This also means it will be easier to move my site if I ever need to since I own the subdomain.
My website is hosted at Bluehost. A lot of people online recommend Bluehost and seem to like it (a lot of these people also use affiliate links for Bluehost so they make money from this recommendation). I found it to be very slow, especially for new sites, but I haven’t found a better solution yet and it is cheap and fairly straightforward to manage domains there so that is what I am working with for now.
Adding a subdomain in the Bluehost portal was easy but getting it to point to another url was not well documented so I list the steps I took below for future reference and in case others also struggle to figure it out!
How to set up a custom subdomain for a GitHub pages site
Requirements
- A Bluehost account with a primary domain already set up
- A GitHub pages site already set up (read how I set mine up here)
- 24-48 hours to wait for the subdomain to propagate
1. Create a Bluehost subdomain
- Log in to Bluehost
- Navigate to
Domains
thenSubdomains
in the menu (to the left in my Bluehost portal page) - Click on the
Add subdomain
button to the top right - Fill in the boxes with the name of your subdomain and select your existing domain in the dropdown menu. This is how mine looked:
- Click add subdomain
- Wait 24-48 hours for this to propagate
2. Point a Bluehost subdomain to your GitHub pages site
This was the poorly documented part. You will need to add a CNAME record that points your subdomain to your GitHub pages site. How to add a CNAME record in Bluehost is well documented but what it does not mention is that first you have to remove the A records and TXT records Bluehost already added for your subdomain since it won’t allow you to create a CNAME record with the same name (and you will get the error message There was an issue adding the zone records. New Record was not inserted.
)
- Log in to Bluehost
- Navigate to
Domains
- Find your primary domain in the list and click on
Manage
. This should take you to the DNS manager. - Scroll to the list of A records and find the one associated with your new subdomain (for me this was called
open-research
: you may need to clickShow all
). Remove it by clicking on the three dots to the right and selectingremove
. - Scroll to the list of TXT records and find the one associated with your new subdomain (for me this was called
open-research
: you may need to clickShow all
). Remove it by clicking on the three dots to the right and selectingremove
. - Scroll to the list of CNAME records. Click
Add record
and fill in theHost record
field with your subdomain name and thePoints to
field with your GitHub Pages url. Select the minimum TTL (4 hours) from the drop down menu. ClickSave
. Mine looked like this:
3. Configure GitHub pages to use your custom subdomain
- Navigate to your GitHub pages repo
- Select the
Settings
tab - Click on
Pages
in the menu to the left underCode and automation
- Scroll down to the
Custom Domain
section and add your custom domain name (mine is nowopen-research.gemmadanks.com
) - Wait for the DNS check - if this is unsuccessful it could be that you need to wait longer for your subdomain to propagate.
- To make your site more secure, make sure the box
Enforce HTTPS
is checked - Wait for the GitHub action to redeploy your site
- Scroll back to the top of the page and check that your site now points to your custom domain (visit the site to verify)
Your GitHub pages site should now be live at your custom subdomain! Make sure you pull the changes that were made by GitHub (adding a CNAME file) to your local machine.
Troubleshooting
I found the following command helpful when troubleshooting. It will tell you what your subdomain is pointing to and what type of record it is using. You should see the CNAME pointing to GitHub pages listed. Open a Terminal window and paste in the following:
dig your-subdomain +nostats +nocomments +nocmd
Comments