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

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.

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

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

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

This 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 .txt file when it was downloaded. The file that is added to the static folder should not have a filetype ending it should just be CNAME with 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.

One hang up I had was the CNAME file I downloaded as an example was converted to a .txt file when it was downloaded. The file that is added to the static folder should not have a filetype ending it should just be CNAME with the custom URL as it’s contents.

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-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 👍