I have a GitHub repository set up to host a small static site. The repository that hosts this is in the following format:
username.github.io
This repository is setup to use a custom domain and has a CNAME file to do so properly. This repository works exactly as expected.
Now I want to set up a project page and utilize the gh-pages
branch for a different repository. When I do this, though, the CNAME in the first repository seems to apply and I am redirected to example.com/REPOSITORYNAME
instead of using the expected username.github.io/projectname
associated with this separate repository.
How can I continue to use the username.github.io
repository with a custom domain and the gh-pages
branch on a different repository without redirecting the gh-pages
repository to the custom domain defined in the first repository?
Best Answer
One solution would be to rename your
username.github.io
repository to something else, so it is no longer considered to be your special "user/organization pages" repository. It can continue using the custom domain it's already on (just make sure theCNAME
file in the repository correctly points to yourexample.com
custom domain). Then, your projects pages should start usingusername.github.io
instead of the customexample.com
.