I have a couple of issues I believe are related regarding githubpages.
First, when trying to create my user page by naming the repo the same as my username, I expect the url to be this myusername.github.io
.Instead it looks like this myusername.github.io/myusername
.
I have been to work around this by naming my repo myusername.github.io
, which produces the correct URL.
Now, I want to create a custom domain with this user page. I can use my custom domain with the above workaround, but this now affects all other repos which use github pages. For example, I setup myusername.github.io
to use mycustomdomain.com
. But now I have another project that uses gh pages called someotherproject
. The url now redirects to mycustomdomain.com/someotherproject
instead of someotherproject.github.io
.
Is this working correctly?
But now I have another project that uses gh pages called someotherproject. The url now redirects to mycustomdomain.com/someotherproject instead of someotherproject.github.io.
This is what described in the official documentation "Supported custom domains"
After you configure a custom domain for a user or organization site, the custom domain will replace the
<user>.github.io
or<organization>.github.io
portion of the URL for any project sites owned by the account that do not have a custom domain configured.For example, if the custom domain for your user site is
www.octocat.com
, and you have a project site with no custom domain configured that is published from a repository calledocto-project
, the GitHub Pages site for that repository will be available atwww.octocat.com/octo-project
.
That was reported as an issue in 2016:
I'm afraid this can't be disabled. If you have a CNAME file in a User pages site you other project pages will redirect to this Url.
You can override it by adding a different CNAME to your project page though or just create another Project site to act as your user page.
In 2020, here is a possible workaround, mentioned by Oliver Vorasai:
The Problem
- Have portfolio repository at https://github.com/username/username.github.io
- https://github.com/username/username.github.io uses custom domain at
www.username.com
- Created another project at https://github.com/username/my-new-project
- Create
gh-pages
branch so Github Pages will host itmy-new-project
should be accessible at https://username.github.io/my-new-project/- https://username.github.io/my-new-project/ it is automatically redirected to www.username.com/my-new-project and causes 404.
The Solution
- Rename the https://github.com/username/username.github.io repository to https://github.com/username/username-something
- https://github.com/username/my-new-project should now be available at https://username.github.io/my-new-project/
- www.username.com is still working, subsequent projects should get standard Github Pages urls without custom domains.
Not ideal though, as mentioned by Emma Sax :
I still think the best solution would be an option in the GH Pages settings of a project page to not redirect the domain of a project page.
This way, users would have a choice of having
username.github.io/project-page
redirect towww.customdomain.com/project-page
or having it stay where it is.It's frustrating to me that we even need to find an alternative solution at all.