How to Add Github.io to Namecheap Domain

As you probably know, you can create username.github.io, and Github will host your static website. What if you want this username.github.io to be a different domain name that you purchased on namecheap? Let’s say that I have buhpc.github.io, and I want it to be buhpc.com, which I have purchased on namecheap. How exactly do I do that?

Add CNAME to username.github.io

We should add CNAME to our username.github.io. We can easily do this through the terminal or website GUI. I’ll show you how to add a new file called CNAME on the website GUI. We’ll visit http://github.com/buhpc/buhpc.github.io. There’s a New file button next to New pull request button. Click it.

github-io-website

Now, we name the file, CNAME. Inside the large text box, we write the name of the domain that we have purchased on Namecheap. For me, I wrote buhpc.com inside the file. At the bottom, we click the Commit new file, green button.

add-a-CNAME

Now, what we see is that we have committed the CNAME file, and it appears within our git repo.

CNAME-added

 

Adding the Host Records to Namecheap

We visit https://namecheap.com and log into our account. On the list of domains that we own, hit Manage next to the domain that we want to link to github.io.

manage-subdomain

Now, we want to select the Advanced DNS tab.

advanced-dns

At the bottom, we can add the following four Host Records as part of the Advanced DNS.

Make sure that you hit Save All Changes.

what-to-add-to-namecheap

After waiting up to 30 minutes, when you visit buhpc.github.io, your site should redirect to buhpc.com and vice versa. Visit your username.github.io or your domain name!

How to Add Subdomains on Namecheap

Adding subdomains on Namecheap is quick and easy. Let’s say that I have a remote computer with IP address, 128.197.115.158. I want to be able to SSH into this machine, but I hate needing to remember the IP address. Well, if you have purchased a website domain name on Namecheap like I have, just add a subdomain to your website! One of my websites that I have registered with Namecheap is http://buhpc.com, so I’ll be using that as the example.

 

Sign into Namecheap and hit Manage near your website domain name

We’ll sign into Namecheap and hit Manage at the right side of our website domain name. If you don’t have a Namecheap domain name registered yet, you can use search to find and purchase one that you like.

manage-subdomain

 

Click the Advanced DNS tab

We will be brought to the domain information page. There will be an Advanced DNS tab that we want to click.

advanced-dns

 

At the bottom of the Host Records, you’ll see the option to Add New Record.

We want to hit Add New Record.

add-new-record

 

Add the Host Record.

We will in the information of the Host Record that we’ll add. We’ll use Type, A Record. The Host represents the subdomain part. I use an easy number to remember like 1, so that the IP will route to 1.buhpc.com. The Value will be the IP address that you want to connect the subdomain to. TTL should be automatic. After you have filled in your subdomain host record information, you can hit the checkmark on the right side, and the host record saves.

add-a-record-subdomain

 

Wait for 5 minutes or so. Ping or SSH into your subdomain.

The configuration may take as short as 5 minutes to up to an hour. After waiting, ping or SSH into your subdomain. In my case, when I SSH into my 1.buhpc.com, I can see in parentheses that it has the IP address that I gave to it.

ssh [email protected]

ssh-into-subdomain