Multiple GitHub Pages and custom domains via DNS

Go To StackoverFlow.com

64

I want to have one user page and multiple project pages hosted by GitHub Pages but available under ONE custom domain (with subdomains for each GitHub Pages repository, of course). So my goals are as follows:

As of my current understanding, GitHub Pages do only allow ONE CNAME resource record for a page (both user pages and project pages) defined in the CNAME file in the root of a Git repository. I already tried out many things (playing around with DNS records and header redirects at my domain provider EUserv, but I can only access my GitHub user pages under one URL (http://blog.florianwolters.de). I am aware that DNS changes can take up until two days.

Can somebody explain to me, how I can achieve the goals described above? I can not believe that this is not possible but I am also no expert for DNS, etc.

If the above is not possible: What is your suggested workaround? I do want to access all my GitHub pages under one domain (and the subdomains of that domain).

Resources

2012-05-21 13:14
by Florian Wolters
Not possible. See Multiple domains in CNAME file on My custom domain isn't workingBengt 2013-04-06 21:05
This blog post details the issue. http://captainwhippet.com/blog/2014/05/11/blog-setup-details.htm - Steve Moser 2015-02-02 22:35


63

You can do it. Notice that all DNS CNAME entry point to the same host.

1: github.com/florianwolters/florianwolters.github.com

CNAME file content: blog.florianwolters.de

DNS CNAME: blog > florianwolters.github.com

2: github.com/florianwolters/pear/tree/gh-pages

CNAME file content: pear.florianwolters.de

DNS CNAME: pear > florianwolters.github.com

2012-05-22 12:44
by Joseph Fneisz
OK, the file content of both CNAME files and the first CNAME resource records do already match your suggested values. I changed the second DNS CNAME record. I will report tomorrow if it works. Also, one part of my question remains: Which CNAME records do I have to create to reach blog.florianwolters.de via florianwolters.de and www.florianwolters.de? I can't make this work. Even a header redirect does not work?! Nontheless, thanks so far - Florian Wolters 2012-05-23 12:39
If you are using a top-level domain like florianwolters.de, you must use an A record pointing to 204.232.175.78. This way you will get a redirect to the www, wich is pretty standard. I think you have to create a separated www project as well. the only reamining problem is then how would you redirect from the www to the blog? this is need to be done ideally on server side, that is involving some kind of server side language/framework combo to run on the www subdomain, and in this case github can't help you much. examples: github.com/thoughtnirvana/www_redirec - Joseph Fneisz 2012-05-23 19:00
Your answer was the solution to my problem. Now I can host as many projects as I want via subdomains. That's awesome! See my answer for a final clarification. I got it work server-side (at my domain registrar) with two simple header redirects. That's sufficient for my demands. The reason, this hasn't worked before was, that I deleted the default A resource records (pointing to an IP of my domain registrar). Hence the header redirects didn't work - Florian Wolters 2012-05-26 13:45
i'm glad it worked : - Joseph Fneisz 2012-05-29 16:21
Is this still working? Looks like Github is now only supporting the gh-pages branch... that sound right - Ryan Angilly 2013-09-17 20:32
Jesus Mary Christ : - Deming 2015-12-02 18:11
Thank you very much, it's still working and it's amazing - Kalitine 2015-12-26 15:42


5

You can either use one CNAME resource record or one A resource record together with GitHub Pages.

So, in conclusion one have to decide:

  • Either you use example.org and www.example.org (replace the existing A record with 204.232.175.78) ...
  • ... or a subdomain, e.g. blog.example.org (create a new CNAME record with <username>.github.com).

Now, you have to choose how-to map from one (sub)domain to another:

  • If using the first you can use redirects by utilizing HTTP headers from the desired subdomain(s) to example.org.
  • If using the latter you have to use header redirects from example.org and www.example.org to the desired subdomain(s).

Also, see GitHub Pages Help for help and my GitHub Pages repository for an example CNAME file.

Edit: GitHub Pages added a detailed page that describes how-to set up a custom domain here.

2012-05-26 13:32
by Florian Wolters
Can you clarify some more: What do you mean with: "... use header redirects from the desired subdomain(s) to example.org." Do you mean to create CName record on your dns? DNS CNAME pear --> example.org ?? OR DNS CNAME pear --> userename.github.com ? - elviejo79 2013-04-17 20:26
@elviejo: I believe what he meant was to use redirects using HTTP headers - damd 2013-05-25 22:18


1

You can only have one CNAME resource record for a page (both user pages and project pages) defined in the CNAME file in the root of a Git repository.

You can circumvent this by creating a CNAME record for your host(pear) in your DNS settings pointing to florianwolters.github.com, and making a entry in your CNAME file in repository for pear.florianwolters.de

2018-04-26 08:21
by goyuiitv
Ads