Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying seems to overwrite custom domain #213

Open
unlikenesses opened this issue Nov 13, 2017 · 5 comments

Comments

Projects
None yet
6 participants
@unlikenesses
Copy link

commented Nov 13, 2017

I am deploying a GatsbyJS site to GitHub pages with this command:

gatsby build --prefix-paths && gh-pages -d public -b master

I need to push to the master branch because it's a user site (rather than a project site). This works but each time I do it, the repo's "Custom domain" setting is reset. This means after every deploy I need to go into the settings and re-enter the custom domain. No idea if this is a bug or if I'm just missing something obvious.

@atav32

This comment has been minimized.

Copy link

commented Nov 15, 2017

also getting this bug...

@youfoundron

This comment has been minimized.

Copy link

commented Nov 24, 2017

@unlikenesses @atav32

It seems you need to include a file named CNAME at the root of your file structure.
Your custom domain should be the first line in this file.

In my case, the CNAME file would have this content:

youfoundron.com

Credit goes to this comment.

@pablorsk

This comment has been minimized.

Copy link

commented Dec 23, 2017

Just adapt this lines to your DEPLOYMENT script

var ghpages = require('gh-pages');
var fs = require('fs');

fs.writeFile('dist/CNAME', "your-custom-domain.com", function(err) {});
ghpages.publish('dist', function(err) {});
@dijs

This comment has been minimized.

Copy link

commented Feb 13, 2019

I came across the same issue and just added a npm script for this before publishing.

"add-domain": "echo \"customdomain.com\" > build/CNAME",
@vittorio

This comment has been minimized.

Copy link

commented Mar 30, 2019

If you use gh-pages for React app deployment – just put CNAME file with your domain into public folder.

kosich added a commit to onepagehistory/onepagehistory that referenced this issue Apr 10, 2019

Added CNAME file, see description
Github pages custom url was reset after each deployment
For details see tschaub/gh-pages#213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.