Search code examples
gitgithubrepositorysubdomaingithub-pages

can I create a subdomain for my github pages site?


for example, I have this github pages site: foobar.github.io

I have a repository named repo and I want to make a subdomain for that like this: repo.foobar.github.io

Is that possible? How can I do that?

I get this error when I want to choose repo.foobar.github.io as custom domain for repo's github pages settings:

 You cannot use CNAMEs ending with github.io, github.com, or github.page. Instead, create a repository named AshkanLaei.github.io. See https://docs.github.com/articles/setting-up-your-pages-site-repository/ 

Solution

  • No you cannot.

    Since you don't own/control the github.io domain and its DNS settings, you cannot set that up. And they do not allow you to set that up.

    One option you have is to use a subdirectory instead of a subdomain. They do allow you to have things like foobar.github.io/anotherrepo

    More info about the types of GitHub Pages sites:

    https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites

    More info about custom domains/subdomains for your GitHub Pages site:

    https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/configuring-a-custom-domain-for-your-github-pages-site