Github Pages with single custom (sub)domain for multiple repositories

I have multiple Github Repositories. By all of them pages are enabled, and the projects are accessible via paths for example:

  • username.github.io/project1 ,
  • username.github.io/project2 ,
  • ...

Now I’m trying to create a custom subdomain docs.foo.tld and to have all my projects gh-pages to be accessible via

  • docs.foo.tld/project1
  • docs.foo.tld/project2
  • ...

I have created a CNAME entry docs.foo.tld to username.github.io

And when I’m adding this custom domain ( docs.foo.tld ) in project1 repository settings on github, the pages are directly accessible via docs.foo.tld , not via docs.foo.tld/project1

How I use all this projects in the path segments /project1 , /project2 when using same custom subdomain for all of them.

When I try to add this custom subdomain to project2 , I get the exception as the CNAME is already taken.

I don’t think github pages can do what you want the way you’re trying to do it.

You could just merge all the docs into a single repository.

Or you could use your own hosting service and have it do this for you.

Hello and welcome here!

I have created a CNAME entry docs.foo.tld to username.github.io

This should be sufficient. The special repository named <your username>.github.io is what we call your user site. If you set a custom domain on that repository, all your other Pages sites (project sites) will automatically route on that new domain. Only one repository at a time can be associated with a given custom domain (we enforce the unicity).

You can learn more about the different type of Pages sites here: About GitHub Pages - GitHub Docs.