1

I'm looking to host two very different sections of my website in the same GitHub Pages site. For example, say I a section of my website hosts cat videos, and one that hosts dog videos, and both are light enough to fit within the limits of my Pages repo.

What I want is for the link meow.example.com to take you to the cat section of the page, and bark.example.com to take you to the dog section of the site. This is of course assuming I already own the example.com domain on GoDaddy or whatever other domain registrar.

I know for a fact that this can be done (ex: en.wikipedia.org vs es.wikipedia.org). Is this possible to do with GitHub Pages? If not, what would I be required to do with another hosting service?

1 Answer 1

0

Yes, this is possible to do using GitHub Pages. Custom subdomains are among the types of custom domains supported by GitHub Pages.

For general info, see About custom domains and GitHub Pages - Using a subdomain for your GitHub Pages site.

For detailed set-up instructions, see Managing a custom domain for your GitHub Pages site - Configuring a subdomain

In essence, the steps to get this set up are:

  1. Go to your GitHub repo settings and add your desired subdomain as a "custom domain". This will generate a commit in your GitHub repo that creates a "CNAME" file at the root of your repo, containing your custom subdomain.

  2. At your DNS provider (commonly your domain registrar), create a CNAME record that points to [username].github.io.

  3. Wait for the DNS linkage. That's it, you're done.

2
  • So the thing is by using this method, I can have meow.example.com OR bark.example.com, not both. I need to have meow.example.com AND bark.example.com, both leading to different sections of the site
    – sdass
    Mar 14 at 18:24
  • Oh. I may have misread your question. I didn't realize both subdomains need to be managed under a single repo. Subdomains are typically used to separate sites across infrastructure, so it's not very common to have a single repository serve out to multiple subdomains like that. Typically you would use subfolders instead. So as a revised answer, it is impossible to serve multiple subdomains from a single repository using only GitHub Pages. You would need to involve another separate web hosting, CDN or reverse proxying service to get it to work. Mar 15 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.