Greg Wolff
Greg Wolff

Reputation: 188

Can you add multiple custom domains to multiple Github repositories?

I know that you're able to create subdomains redirect to different repositories like:

example.com
foo.example.com

But are you able to do something like:

example.com > foobar.github.io
differentdomain.com > foobar.github.io/different-repository

Or have some way to have a new custom domain redirect to a specfiic repository?

Upvotes: 8

Views: 2016

Answers (1)

phd
phd

Reputation: 94397

To have Github Pages at foobar.github.io you need a user (or "organiaztion") account at github.com/foobar and a repository at github.com/foobar/foobar.github.io.

To have Github Pages at foobar.github.io/different-repository you need a branch gh-pages at github.com/foobar/different-repository.

To configure example.com to show foobar.github.io you add DNS records A to the domain pointing to Github Pages IP and add a file github.com/foobar/foobar.github.io/CNAME with content "example.com" (don't forget to add, commit and push).

To configure differentdomain.com to show foobar.github.io/different-repository you add DNS records A to the domain pointing to Github Pages IP and add a file github.com/foobar/different-repository/CNAME in gh-pages branch with content "differentdomain.com" (add, commit, push).

Upvotes: 9

Related Questions