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:
- Login to Github and create a repo by the name username.github.io. For more details visit: https://pages.github.com/
- Upload your template file and visit your github page. It should load your website.
- 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.
- Upload this file to your repo as well.
- Next login to your domain register and update the A record that maps the domain to the Github’s IP address which is 22.214.171.124 and 126.96.36.199 (as per Github docs)
- 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.