7

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?

7
  • Did you generate the static files through Angular2 or Reactjs build?
    – Willian
    Jun 19, 2020 at 2:57
  • No. They're generated through a Python script I wrote that processes some Jinja templates, but I'm hoping for a solution that's independent of how the static pages were generated.
    – Michael A
    Jun 19, 2020 at 9:00
  • 1
    Is your project public? I can have a look at this by forking it into my account... Considering what you have done so far, it was supposed to work as expected.
    – Willian
    Jun 19, 2020 at 20:21
  • 2
    Where is your CNAME file? Is it in the root of your repo or in the /docs folder? If it is in the root of the repo, can you please try to move it to the /docs folder?
    – Chun Liu
    Jun 21, 2020 at 2:28
  • 1
    @MichaelA Glad to know it solved the problem. I'll post it as an answer. :)
    – Chun Liu
    Jun 22, 2020 at 2:22

1 Answer 1

2
+50

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.