How to configure DNS to point to github project pages? - github

I have a domain name with name.com and my project's github pages is
my_username.github.io/project's name/
and I read this from their docs
CNAME does not resolve to URLs - i.e http://name.com/support - because it cannot handle special characters like : and /
so I am stuck here. Because I haven't seen many using A record, I wonder if it can be used with github pages. Thanks.

The DNS domain configuration is normally reserved for User & Organization pages, not for Project Pages.
For project page, you need to:
create a CNAME entry point to my_username.github.io. (note the final '.'!).
add a CNAME file to your project root in the gh-pages branch (with name.com as its content).
See:
"Custom domain for GitHub project pages",
"Redirecting Github project pages to a custom domain" by Zara Rahman.

Related

Github Pages with single custom subdomain for multiple repositories (using paths)

I have multiple Github Repositories. By all of them gh-pages are enabled, and the repositories are accessible via paths for example:
username.github.io/repository1,
username.github.io/repository2,
...
Now I'm trying to create a custom subdomain docs.foo.tld and to have all my repositories gh-pages to be accessible via
docs.foo.tld/repository1
docs.foo.tld/repository2
...
I have created a CNAME entry docs.foo.tld to username.github.io
But when I'm adding this custom domain (docs.foo.tld) in repository1 repository settings on github, the gh-pages are directly accessible via docs.foo.tld, not via docs.foo.tld/repository1
How I use all this repositories in the path segments /repository1, /repository2 when using same custom subdomain for all of them.
Also to note, when I try to add this custom subdomain to repository2, I get the exception as the CNAME is already taken.
The CNAME and setting the custom domain should only be done in the .github.io repo.
Other repos should not contain a CNAME and you should not set the custom domain in the other repositories. Those settings are inherited from .github.io repo and setting them in the other repositories is overwriting the root site.
Just delete the CNAME records from the project repos, and remove the custom domain from the settings of the project repos. You may need to add the custom domain name back to the .github.io repo, but after that you should be all setup like you wish.
I had the exact same problem, but with the root account being an Organisation, not a User site (but this makes no difference). The solution is surprisingly simple (I had many trials and errors):
If not yet done, create the special Organisation/User "umbrella" Site as per the doc by creating a git repository called myorg.github.io.
In the Settings of that repo, under the "Pages" tab, choose your custom domain docs.mydomain.com. See picture:
The content of this repo is up to you. Personally I use VitePress with a small script which deploys at the root of the gh-pages branch. The script includes the creation of a CNAME file at the project root, with the content `docs.mydomain.com'
Configure your DNS zone with your Internet Provider by adding a CNAME entry pointing to myorg.github.io. (note the trailing dot – your IP may or may not add it automatically for you).
Return to the Pages Settings of your GitHub umbrella repo, and check that the subdomain is validated (it may take a few minutes).
That's all for the umbrella docs site, whose content contains links to docs.mydomain.com/project1, docs.mydomain.com/project2 etc.
Now, here is the trick: there is no trick. In all of your real projects, simply deploy your documentation. You can do so in the docs subfolder or not, in either branch, that is, in the master or gh-pages one, it doesn't seem to matter.
If any, the docs/ part of the url will be replaced by project1/ etc. There is no need for a CNAME, and no need for another custom subdomain.
Here is the config of one my project:
See how GitHub indicates under which URL the site is published.
Here is my GitHub organisation and its umbrella site
and the results:
https://docs.arcsecond.io
https://docs.arcsecond.io/cli
https://docs.arcsecond.io/oort
Bonus. If by any chance you configure your projects to have sub-subdomains (that's what I tried before finding the solution) – such as https://project1.docs.mydomain.com, the above configuration will also "work". That is, navigating to https://docs.mydomain.com/project1 will redirect you to https://project1.docs.mydomain.com
Internet is kind of amazing, isn't it?

How do I serve a Github page through a custom domain when the content is stored in the docs folder?

I have a project site in Github that is served through a custom domain (rented through Google Domains). I first configured the repository to serve directly from the master branch, and configured the DNS records in Google accordingly.
Specifically, the A record is set to
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
and the CNAME record is set to myusername.github.io. In the Github repository, I created the CNAME file with mycustomdomain.org and changed the repository settings to use it. This works properly.
However, once I change the Github Pages setting to use the /docs folder on the master branch, I can't access the site through mycustomdomain.org. (It's a 404 error) Intuitively, it's now at mycustomdomain.org/docs. Is there any way to both serve the pages from the docs folder and access the site through the top-level domain?
Moving CNAME file from the root of the repo to the /docs folder solved the problem.
Reference: The CNAME errors are mentioned here in GitHub documents.

Use Github pages on multiple repositories when one has a custom CNAME already?

I have a Github repository set up to host a small static site. The repository that hosts this is in the following format:
username.github.io
This repository is setup to use a custom domain and has a CNAME file to do so properly. This repository works exactly as expected.
Now I want to set up a project page and utilize the gh-pages branch for a different repository. When I do this, though, the CNAME in the first repository seems to apply and I am redirected to example.com/REPOSITORYNAME instead of using the expected username.github.io/projectname associated with this separate repository.
How can I continue to use the username.github.io repository with a custom domain and the gh-pages branch on a different repository without redirecting the gh-pages repository to the custom domain defined in the first repository?
As of Aug 2016, I don't think this is possible. (https://help.github.com/articles/custom-domain-redirects-for-github-pages-sites/)
The Github Pages help article states that
Project Pages site owned by a user account, such as username.github.io/projectname, will be Automatically redirected to a subdirectory of a User Pages site custom domain (user.example.com/projectname), unless a different CNMAE is specified, such as project.example.com
See Github pages - Disable custom domain redirection for all but a single site?
The easiest way is to create a Github Organisation for each website you decide to manage this way.
In this case, I had to publish to master instead of gh-pages.
More informations here : https://help.github.com/articles/user-organization-and-project-pages/

stop github project page subpath redirecting to custom subdomain

I have a GitHub pages set up with a custom domain.
I have some project pages which I would like to be available at project.domain.com, in addition to being available at domain.com/project.
Setting up the project repository with a CNAME file, and adding a CNAME record to the dns will make project.domain.com work, but redirects domain.com/project to project.domain.com.
Is there a way to have both URLs serve the same project page, without either redirecting to the other?
This question asks the opposite, how to automatically redirect from a subpath to a subdomain, but both options (A records or CNAME records) don't work for me.
You cannot have both.
You project repository is served as a folder of :
username.github.io -> username.github.io/projectname
or domain.com -> domain.com/project, if you add a CNAME for domain.com in username.github.io
If you add a CNAME in a project repository, an automatic redirection is applied in accordance with this CNAME content. In your case project.domain.com.

How to set up two jekyll blogs on Github Pages with the same domain (CNAME)

I have two blogs hosted on Github Pages: travel and personal. The first should appear on http://alkamid.com/travel, the second on http://alkamid.com — and they do, but after pushing the travel CNAME with the same content as the personal one (just one line: alkamid.com), I got the following warning from Github:
The page build completed successfully, but returned the following
warning:
CNAME already taken: alkamid.com
I didn't change anything in the settings of my domain provider.
What is the correct way of configuring CNAME for these two blogs?
Remove CNAME from your /travel repository. You just need it in your username.github.io repository.
Edit : This is my point of view about CNAME on github pages (ghp)
The simplest ways to manage custom domain on ghp is to set a CNAME (pointing to example.com) on username.github.io and any project repository hosting a gh-pages branch can be naturally reached at example.com/repositoryName. This is my solution.
But you can always set another CNAME on a particular project repository, for a subdomain (sub1.example.com) or another domain (example.org). This just implies to set a custom DNS. And here it's your choice.