Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 624
Michael A Avatar asked Jun 01 '20 17:06

Michael A


1 Answers

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.

like image 127
Chun Liu Avatar answered Nov 09 '22 14:11

Chun Liu