Search code examples
githubgithub-pages

How to set third level domain for GitHub project page


I have set a custom domain for my personal GitHub page and all my projects GitHub pages are like,

mydomin.com # <- My GitHub Account Page
mydomin.com/project1 # <- Project 1 gh-pages
mydomin.com/project2 # <- Project 2 gh-pages

Is there a way to make the domain name for my project GitHub page using 3rd level domain project1.mydomin.com instead of mydomin.com/project1.

I tried to set up using CNAME but cloudflare seems does not allow me to set username.github.io/project1 as an alias. When I using @project1 to represent the root domain, which make the link into mydomin.comproject1. All other combinations are invalid hostname.

Thanks for your time viewing this question.


Solution

  • All you need to do is the following,

    1. Set the DNS (See image below, Cloudflare is the server I choosen), the value should be your account GitHub page username.github.io.

    enter image description here

    1. Create a CNAME file which contains the 3rd level domain. For example, bus.li-xinyang.com

    And that's it. Now you can name the whatever the project name you like without worrying the gh-pages url.