gh-pages: Custom domain gets deleted on deploy - CNAME not working
I have an issue where each time I use gh-pages to deploy, my custom domain gets deleted. I tried adding a CNAME file to my project with the domain name, but it doesn’t change anything. Each deploy I have to manually set the domain again.
I run gh-pages -d public when deploying.
You can see the project repo here: https://github.com/whoisryosuke/ryosuke-gatsby-blog
Not sure if this is an issue with my stack (GatsbyJS) or the gh-pages lib.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 45
- Comments: 21
Links to this issue
Commits related to this issue
- adding CNAME to work-around GitHub bug where it looses custom domain on gh-paged deployment ... see: https://github.com/tschaub/gh-pages/issues/236 — committed to KevinAst/MyWeb by KevinAst 8 years ago
- keeping CNAME in dist after https://github.com/tschaub/gh-pages/issues/236 — committed to niko7o/nikoto.dev by niko7o 7 years ago
- Move CNAME to public folder to prevent it to be deleted when deploying to gh-pages branch See https://github.com/tschaub/gh-pages/issues/236 — committed to mathildebuenerd/portfolio-gatsby by deleted user 6 years ago
- Add CNAME file to ensure github doesn't lose custom domain https://github.com/tschaub/gh-pages/issues/236 — committed to RockRobotic/rock-doc by deleted user 6 years ago
- generate CNAME file for github static page service Otherwise github unsets the custom domain service on a push the CNAME file in the root publish directory works around that See https://github.com/t... — committed to digikata/digikata.github.io by digikata 6 years ago
- generate CNAME file for github static page service Otherwise github unsets the custom domain service on a push the CNAME file in the root publish directory works around that See https://github.com/t... — committed to digikata/digikata.github.io by digikata 6 years ago
- Create CNAME - add this with deployment output as per https://github.com/tschaub/gh-pages/issues/236 — committed to think-mm/bnsite by think-mm 6 years ago
- Add CNAME as a workaround Related https://github.com/tschaub/gh-pages/issues/236 — committed to hyochan/react-native-iap by hyochan 5 years ago
- Move CNAME to static folder per https://github.com/tschaub/gh-pages/issues/236 — committed to rjc123/robincarswell.com by rjc123 5 years ago
- Update CNAME - add this with deployment output as per tschaub/gh-pages#236 - arc = archive — committed to think-mm/bnsite by think-mm 5 years ago
- Added CNAME to public https://github.com/tschaub/gh-pages/issues/236#issuecomment-606263317 — committed to noxware/noxware.github.io by noxware 5 years ago
- Add static CNAME https://github.com/tschaub/gh-pages/issues/236 — committed to davegallant/site by davegallant 5 years ago
- Create CNAME - add this with deployment output as per tschaub/gh-pages#236 — committed to atiq-cs/note by atiq-cs 5 years ago
- Create CNAME, arc refers to archive - add this with deployment output as per https://github.com/tschaub/gh-pages/issues/236 — committed to think-mm/bnsite by think-mm 6 years ago
- Create CNAME, arc refers to archive - add this with deployment output as per https://github.com/tschaub/gh-pages/issues/236 — committed to think-mm/bnsite by think-mm 5 years ago
- Create CNAME, arc refers to archive - add this with deployment output as per https://github.com/tschaub/gh-pages/issues/236 — committed to think-mm/bnsite by think-mm 5 years ago
- Create CNAME - add this with deployment output as per tschaub/gh-pages#236 — committed to atiq-cs/note by atiq-cs 5 years ago
- CI/CD to deploy statiq site and Create CNAME - deployment yml file - set checkout submoodule to true so that theme is included CNAME ref: add this with deployment output as per tschaub/gh-pages#236 — committed to atiq-cs/note by atiq-cs 5 years ago
- CI/CD to deploy statiq site and Create CNAME - deployment yml file - set checkout submoodule to true so that theme is included CNAME ref: add this with deployment output as per tschaub/gh-pages#236 — committed to atiq-cs/note by atiq-cs 5 years ago
- CI/CD to deploy statiq site and Create CNAME - deployment yml file - set checkout submoodule to true to include theme - actions/checkout: - use traditional tagged version - utilize release configura... — committed to atiq-cs/note by atiq-cs 5 years ago
In your instance add the CNAME file to the static folder.
For those who use
create-react-app, put the CNAME file in the public folder and it will be part of the build output.Also getting this issue
Ah right, for anyone else having this issue just keep a
CNAMEfile in thedistfolder or whatever you’re deploying from (I guess this is the static folder referred to above). So if your deploy script is"deploy": "gh-pages -d dist"then keep a copy indist.@ivoilic I was able to resolve this by committing the CNAME file to the branch gg-pages deploys from.
Just to add some context to this excellent solution from adamsandle, here’s the documentation on the static folder. If it doesn’t already exist, you’ll need to create a directory called
staticat the root of your project.@leslieoa should be something like (assuming you push to origin):
git checkout gh-pages git add CNAME git commit -m ‘:wrench: Added CNAME’ git push gh-pages originThis is a pretty old thread, but where I found the answer to this question. One hang up I had was the CNAME file I downloaded as an example was converted to a
.txtfile when it was downloaded. The file that is added to the static folder should not have a filetype ending it should just beCNAMEwith the custom URL as it’s contents.For angular 8. Create a CNAME file inside the src folder. then Inside angular.json “assets”: [ “src/favicon.ico”, “src/assets”, “src/CNAME” // This is the change you need to make. ],
I’m also having this issue. You have to manually re-enter the costume domain in the repos settings and in my case turn off force https.
Thank you so much, I’ve been trying to fix this for 15 minutes and this was the issue.
@adamsandle the CNAME file is in the
gh-pagesbranch when I deploy (https://github.com/whoisryosuke/ryosuke-gatsby-blog/blob/gh-pages/CNAME), but I’ll add it to the static folder and see if it makes a difference 👍