Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple GitHub Pages and custom domains via DNS

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:

  • One user page (http://florianwolters.github.com) available under http://blog.florianwolters.de, http://www.florianwolters.de and http://florianwolters.de.
  • As many project pages as I wish (e.g. http://florianwolters.github.com/pear available under http://pear.florianwolters.de.

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

  • http://help.github.com/pages/
  • Custom domain for GitHub project pages
  • https://groups.google.com/forum/?fromgroups#!topic/github/AaAuoDK44Ag
  • https://github.com/blog/315-cname-support-for-github-pages
  • http://code.lancepollard.com/custom-domain-github-pages
like image 599
Florian Wolters Avatar asked May 21 '12 13:05

Florian Wolters


People also ask

Can you have multiple GitHub Pages sites?

You can only create one user or organization site for each account on GitHub. Project sites, whether owned by an organization or a personal account, are unlimited.

Does GitHub Pages support custom domain?

You can customize the domain name of your GitHub Pages site. GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

Is custom domain free GitHub Pages?

GitHub Pages is just the solution to that problem. It's free. You can host your website, including custom domain names(https://dhrumil.xyz), 404 error page, sub-domain (https://blog.dhrumil.xyz) and all over secure https.

How many GitHub Pages Can I host?

For each registered GitHub account (representing a user or an organization) you can register one User Page, but an unlimited Project pages.


2 Answers

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

like image 53
marfalkov Avatar answered Sep 19 '22 04:09

marfalkov


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.

like image 35
Florian Wolters Avatar answered Sep 19 '22 04:09

Florian Wolters