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 6 years ago
  • Reactions: 37
  • Comments: 20

Commits related to this issue

Most upvoted comments

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 CNAME file in the dist folder 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 in dist.

In your instance add the CNAME file to the static folder.

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 static at 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 origin

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. ],

@ivoilic I was able to resolve this by committing the CNAME file to the branch gg-pages deploys from.

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.

@adamsandle the CNAME file is in the gh-pages branch 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 👍