Search code examples
githubgithub-pagescustom-domain

Why is custom domain for Github pages not serving pages for other repositories?


Github's About custom domains and GitHub Pages forum reads,

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 called octo-project, the GitHub Pages site for that repository will be available at www.octocat.com/octo-project.

This is exactly what I want. I made a home repository <user>.github.io (with a basic static html website) for my custom domain and set the custom domain xyz.com and www.xyz.com to direct to <user>.github.io as explained in Managing a custom domain for your GitHub Pages site. Here is how it looks.

Domain Settings

I also added a file CNAME in xyz-repo with contents xyz.com. Now www.xyz.com and xyz.com both point to the html in xyz-rep, perfect.

Here is the issue though, I have another repository with Github pages that I can access by <user>.github.io/other-repo-name but not by xyz.com/other-repo-name or www.xyz.com/other-repo-name.

Any help?


Solution

  • It sounds like you manually created the CNAME file. From the docs at https://help.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site,

    Under "Custom domain", type your custom domain, then click Save. This will create a commit that adds a CNAME file in the root of your publishing source.

    I believe Github's system adds the CNAME commit for you: not sure if it will work if you do it? Or maybe there's a specific branch it has to live in? I'd try removing your manually created CNAME file and using the configuration UI.