DEV Community

Discussion on: How to configure custom Namecheap domain to GitHub Pages

Collapse
greeder59 profile image
Gordon Reeder

I just remembered a problem I had when I set up my github web hosting. Your readers will run into it too.
When you set the Custom domain field in github settings, Github will create a file called CNAME. This will cause git to throw an error message when you try to do the next git push.
To deal with this:

  • Make sure that your local and remote (github) repositories are in sync before setting up the custom domain.
  • Once the domain is setup, do a git pull and merge to get the CNAME file into the local repository.
  • If you are using a static site generator, you need to figure out how to make sure CNAME gets recreated locally with each site build.

OK, so other that. It's really simple. Actually it still is simple. The CNAME file got me caught off guard when I did a custom domain setup. I don't want anyone else to have to deal with that.
Once you are aware of it, and handle it properly, you should be OK.

Collapse
habibcseju profile image
Habib Author

Yeah, I also faced the same git pull issue. Thanks for your suggestion. I will add that