For starters, a subdomain is basically an extension of your base domain. If you’re using GitHub Pages to host your website, the default domain that you get is
<username>.github.io. If you want a custom domain, sites like Namecheap, GoDaddy, HostGator and many more of the like offer a wide variety of domain names that are up for grabs. An example subdomain for a default Github Pages domain would be
I purchased my website’s domain a while back. While this was already a blog-like website, I had intended to separate tech and non-tech related posts. I wanted a
blog subdomain to redirect to my non-tech related posts (because I’m a cheapskate and I don’t intend on buying another domain just for this :p). You can view my non-tech blog at blog.evangelistagrace.me. When I was looking for a tutorial to follow, I found that there was a lack of tutorial online for creating a subdomain for GitHub Pages hosted with Namecheap. So here’s a tutorial for just that.
I created a new repo and moved all my desired posts there. You can name your repo whatever you want. What’s important to note is that your desired repo must have a
index.html file in either your ‘master’ branch or a ‘gh-pages’ branch, depending on which branch you wish to add the subdomain to.
Once you have your repo ready, click on the repo’s settings and add your desired subdomain under ‘Custom Domain’.
Click ‘Save’ and this should have created a CNAME file in your repo. Optionally, tick ‘Enforce HTTPS’ to get the nice green lock beside your subdomain. This will take some time to show.
Log in to your Namecheap account and navigate to your domain list and click on ‘Manage > Advanced DNS > Add new record’.
For ‘Type’ Choose ‘CNAME record’ from the dropdown. For the ‘Host’, enter just the first part of your subdomain (e.g: blog). As for ‘Value’, enter your original GitHub Pages domain, i.e.
<username>.github.io. Set the ‘TTL’ to ‘Automatic’ and save the record.
And that’s it! Head to your new subdomain and don’t fret if you don’t see your webpage yet. Wait a little bit longer and check back in. Your new subdomain should be up and runningin no time.