Github pages

How to redirect username.github.io to your custom domain

If you are a Github user then you would have probably seen repository name like username.github.io. Well Github allows users to have websites for its users and there projects. More details can be found at Github Pages.

You can create your personal website by uploading the files in your repo which goes by the name username.github.io. All you need to do is simply create a website templates and upload it in the repo.

However in this post I am going to tell you how we can redirect the custom github page URL to your custom domain. For example, my github URL is abhijitbangera.github.io which would redirect to abhijitbangera.com when the below mentioned steps are executed.

Here are the steps to follow:

  1. Login to Github and create a repo by the name username.github.io. For more details visit: https://pages.github.com/
  2. Upload your template file and visit your github page. It should load your website.
  3. Now to redirect to your domain create a CNAME file and enter your domain name in it. My CNAME file can be found at https://github.com/abhijitbangera/abhijitbangera.github.io/blob/master/CNAME.
  4. Upload this file to your repo as well.
  5. Next login to your domain register and update the A record that maps the domain to the Github’s IP address which is 192.30.252.153 and 192.30.252.154 (as per Github docs)
  6. And you are done!

Now when you visit username.github.io it would redirect to your domain and the load the template files which you uploaded in the repo.

Note: My repo does not contain any template files. It is created as an example repo for this article.

5 thoughts on “How to redirect username.github.io to your custom domain”

  1. I was curious if you ever thought of changing the page layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or 2 pictures. Maybe you could space it out better?

  2. That is really attention-grabbing, You’re a very skilled blogger. I’ve joined your rss feed and sit up for in the hunt for more of your fantastic post. Additionally, I have shared your site in my social networks

  3. Pretty great post. I just stumbled upon your blog and wanted to mention that I’ve truly loved browsing your blog posts. After all I will be subscribing for your rss feed and I am hoping you write once more soon!

Leave a Reply

Your email address will not be published. Required fields are marked *