Gatsby: Publishing to GH-Pages

Created on 20 Jan 2017  Â·  15Comments  Â·  Source: gatsbyjs/gatsby

For some reason, I can use gatsby build to bundle my app, but when I visit the my gh-pages link: https://rcwestlake.github.io/personalsite-react/ it just shows my projects README.md.

image

I noticed in the docs that a prefixLink may be needed, but is that needed for all my links/routes in my app? Or, do I just need to change the reference in config.toml and the rest just happens? It wasn't very clear.

Here's a link to my repo, if need be: https://github.com/rcwestlake/personalsite-react/tree/gh-pages

Thanks for your help.

Most helpful comment

ghpages throws me an error ---> fatal: A branch named 'master' already exists

My site is a User or Organization Page.

PS C:\Users\frank\Desktop\Proyectos\perfil> npm run deploy

[email protected] deploy C:\Users\frank\Desktop\Proyectos\perfil
gh-pages -d public -b master

fatal: A branch named 'master' already exists.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: gh-pages -d public -b master
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\frankAppData\Roaming\npm-cache_logs\2018-03-23T02_20_42_575Z-debug.log

Why is this happening ?

All 15 comments

You need the NPM package gh-pages and add a "deploy" NPM script to your package.json like in the default starter. After setting this up, run it from your command line like npm run deploy https://github.com/gatsbyjs/gatsby-starter-default/blob/master/package.json#L37

You'll also need a prefixLink set it your config.toml.

Thanks. And should the prefixLink be set to the while github domain (rcwestlake.github.io/personalsite-react or just /)

https://github.com/gatsbyjs/gatsby/blob/master/README.md#deploying-to-github-pages-and-other-hosts-where-your-sites-links-need-prefixes

Thanks @KyleAMathews. I don't mean to drag this along, however, trying to get my site live for interviews. I followed the docs and for some reason still run into issues. I've looked at your starter documentation and blog source code and don't see anything you've done that I haven't. When I run npm run deploy it successfully builds (I think). The screenshot below just stays at Done. Second, the gh-pages branch is not created.

image

Current code: https://github.com/rcwestlake/personalsite-react/tree/rw-fix-build-error

For some reason it looks like the gatsby command isnt running. First verify
your site built correctly by running "gatsby serve-build" then run gh-pages
by itself.

On Tue, Jan 24, 2017, 10:41 PM Ryan Westlake notifications@github.com
wrote:

Thanks @KyleAMathews https://github.com/KyleAMathews. I don't mean to
drag this along, however, trying to get my site live for interviews. I
followed the docs and for some reason still run into issues. I've looked at
your starter documentation and blog source code and don't see anything
you've done that I haven't. When I run npm run deploy it successfully
builds (I think). The screenshot below just stays at Done. Second, the
gh-pages branch is not created.

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22278873/f28f417a-e283-11e6-9630-645a3dfb955d.png

Current code:
https://github.com/rcwestlake/personalsite-react/tree/rw-fix-build-error

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/644#issuecomment-275024382,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVhy2WyWAly_rqzpZenbYDtgY3NJMwks5rVuB9gaJpZM4LpzZn
.

When I run it, only part of it appears. So obviously the build command isn't completing.

What are the two "it"s here? :-) Could you paste another screenshot?

@KyleAMathews a few things are happening. When I run npm run build I believe it successfully builds, however, the process stops at Done:

image

If I run gatsby serve-build after closing out of the above command, it says another "something is already running on port 8000" when nothing is. If I just say 'yes', it runs and everything works fine, so that's all good.

However, when I do npm run deploy or gatsby build --prefix-links, the commands stop here:

image

image

And it doesn't finish.

This is my config.toml. It's the same issue whether I have http://0.0.0.0:8000/ or rcwestlake.github.io/personalsite-react/ in the linkPrefix.

image

However, when I set the linkPrefix to just / it build and I can run npm run deploy. This doesn't create a gh-pages branch. Looking at the gh-pages docs, it looks like I may need to add something like this:

```var ghpages = require('gh-pages');
var path = require('path');

ghpages.publish(path.join(__dirname, 'dist'), function(err) { ... });```

If it's stalling when generating HTML, start adding some console.log in
different places to trace down the problem e.g. your html.js file, the
static-entry file inside the Gatsby package etc.

On Sat, Jan 28, 2017, 2:47 PM Ryan Westlake notifications@github.com
wrote:

@KyleAMathews https://github.com/KyleAMathews a few things are
happening. When I run npm run build I believe it successfully builds,
however, the process stops at Done:

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400004/19d4788c-e567-11e6-80d9-892b5d62ea53.png

If I run gatsby serve-build after closing out of the above command, it
says another "something is already running on port 8000" when nothing is.
If I just say 'yes', it runs and everything works fine, so that's all good.

However, when I do npm run deploy or gatsby build --prefix-links, the
commands stop here:

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400018/89576d40-e567-11e6-862d-81d53d73ee37.png

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400024/baa1d836-e567-11e6-854c-f12d3fad388f.png

And it doesn't finish.

This is my config.toml. It's the same issue whether I have
http://0.0.0.0:8000/ or rcwestlake.github.io/personalsite-react/ in the
linkPrefix.

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400038/e347e9c4-e567-11e6-8ccb-419108528f12.png

However, when I set the linkPrefix to just / it build and I can run npm
run deploy. This doesn't create a gh-pages branch. Looking at the gh-pages
docs, it looks like I may need to add something like this:

var path = require('path');

ghpages.publish(path.join(__dirname, 'dist'), function(err) { ... });```

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/644#issuecomment-275876976,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh-eqKj9imgcQjS35-XT7XAhcVK5Xks5rW7eEgaJpZM4LpzZn
.

image

So when I run build it logs in the html.js file before exports and then logs in the render.

image

And when I run deploy, it gets into the html.js file but doesn't log in the render method.

image

Interesting, though... when I run gatsby build && gh-pages -d public without the prefixLink, it successfully runs through. So it seems the issue is related to prefixLink.

Perhaps add some logging to the prefixLink function then?

On Sat, Jan 28, 2017, 2:13 PM Ryan Westlake notifications@github.com
wrote:

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400209/f92993a6-e56b-11e6-891e-c83922b06425.png

So when I run build it logs in the html.js file before exports and then
logs in the render.

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400207/e541f5e0-e56b-11e6-9b2c-48135ac835ac.png

And when I run deploy, it gets into the html.js file but doesn't log in
the render method.

[image: image]
https://cloud.githubusercontent.com/assets/9679076/22400197/b3484d0a-e56b-11e6-9bd7-febd5bd5d697.png

Interesting, though... when I run gatsby build && gh-pages -d public
without the prefixLink, it successfully runs through. So it seems the
issue is related to prefixLink.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/644#issuecomment-275878425,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh1eOAYZ5PoSbngZQ-TSma46uTu2Cks5rW72BgaJpZM4LpzZn
.

ghpages throws me an error ---> fatal: A branch named 'master' already exists

My site is a User or Organization Page.

PS C:\Users\frank\Desktop\Proyectos\perfil> npm run deploy

[email protected] deploy C:\Users\frank\Desktop\Proyectos\perfil
gh-pages -d public -b master

fatal: A branch named 'master' already exists.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: gh-pages -d public -b master
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\frankAppData\Roaming\npm-cache_logs\2018-03-23T02_20_42_575Z-debug.log

Why is this happening ?

ghpages throws me an error ---> fatal: A branch named 'master' already exists

My site is a User or Organization Page.

PS C:\Users\frank\Desktop\Proyectos\perfil> npm run deploy

[email protected] deploy C:\Users\frank\Desktop\Proyectos\perfil
gh-pages -d public -b master

fatal: A branch named 'master' already exists.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: gh-pages -d public -b master
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\frankAppData\Roaming\npm-cache_logs\2018-03-23T02_20_42_575Z-debug.log

Why is this happening ?

I am having this issue as well.

I'm having this issue as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  Â·  3Comments

signalwerk picture signalwerk  Â·  3Comments

andykais picture andykais  Â·  3Comments

3CordGuy picture 3CordGuy  Â·  3Comments

totsteps picture totsteps  Â·  3Comments