Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can github pages CNAME file contain more than one domain?

Can github pages CNAME file contain more than one domain?

Example file:

reggi.com www.reggi.com blog.reggi.com 
like image 908
ThomasReggi Avatar asked May 09 '13 03:05

ThomasReggi


People also ask

What are the limitations of GitHub Pages?

Usage limitsPublished GitHub Pages sites may be no larger than 1 GB. GitHub Pages sites have a soft bandwidth limit of 100 GB per month. GitHub Pages sites have a soft limit of 10 builds per hour. This limit does not apply if you build and publish your site with a custom GitHub Actions workflow.

Can you host multiple sites on GitHub Pages?

Yes, it is possible to have multiple GitHub Pages sites within one account. Create another GitHub repository and push your site files to the gh-pages branch.

How do I add a CNAME to my GitHub repository?

On your site's repository, click the settings tab . Under custom domain, type your custom domain and save. GitHub will automatically create a commit with a CNAME file at the root of your repository. Visit the dashboard provided by your domain provider and add a CNAME record pointing to your subdomain.

Can you add custom domain to GitHub Pages?

On GitHub, navigate to your site's repository. Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Pages. Under "Custom domain", type your custom domain, then click Save.


2 Answers

No, this is not possible. See the GitHub Help docs that explain this:

Ensure you only have one domain listed in your CNAME file. If you wish to have multiple domains pointing to the same Pages, you will need to set up redirects for the other domains. Most domain registrars and DNS hosts offer this service to their customers.

like image 148
Ivan Zuzak Avatar answered Sep 23 '22 14:09

Ivan Zuzak


Here is one approach that is a Github-only solution using an HTML redirect.

  1. Create an extra repository
  2. Configure it to use Github Pages with the additional domain
  3. Add an an index.html file with the following contents
<!DOCTYPE html> <html>   <head>     <meta charset="utf-8">     <title>Redirecting to https://example.com</title>     <meta http-equiv="refresh" content="0; URL=https://example.com">   </head>    <link rel="canonical" href="https://example.com"> </html> 
like image 43
mpgarate Avatar answered Sep 23 '22 14:09

mpgarate