Prerequisites

The following prerequisites are important as they filter the target audience for this article. However, you can still go through this article if you wish to understand how to link your github pages site to any custom url.

Step 1: Add a cname file

  • Create a “CNAME” file in the root directory of your github website. For this go to the root directory of your github site and click on “Create new file” option on the top of the page. Then type the file name as CNAME and type your url name as the content. Note that you don’t need to use http:// of www. See the sample on my github pages site. for my website. My CNAME file contains codemyway.in without any spaces or any extra text.
  • Commit the changes and you’re done with STEP 1.
  • Log in to your crazy domains account and click on Domains under the My Account section.

    Click on Domains

  • Scroll down to the DNS Settings section and Click on Add Record

    Click on Add record

  • You’ve to add 3 records as shown in the image below. Replace codemyway.in with your url and don’t change any other records. Add two A records pointing to the github pages server 192.30.252.153 and 192.30.252.154. Then add a CNAME record as “www.your_url” which gets linked to ** yourusername.github.io ** which is the default url generated by github pages site. In case of project sites, the CNAME record should point to your_project_repo.github.io.

    Add these records


Anjul Tyagi

General life hacks and learnings.