Create-react-app: Deploying through Github User Pages

Created on 16 Nov 2017  路  5Comments  路  Source: facebook/create-react-app

Upon reading the create-react-app docs, I only know how to deploy via gh-pages by adding a "homepage" section in my package.json. However, that requires the domain name to be <username>.github.io/<repository_name>. I want to deploy via master, with my domain name being <username>.github.io, but Github isn't reading my /build folder correctly. My site is just showing the README.md file.

How do I force Github to look at my /build folder and display my site? I tried renaming /build to /docs which didn't work either.

claimed starter documentation

Most helpful comment

There's a workaround here.

  1. Simply change your default branch for your project to something else like source.
  2. Change your deploy script to push to master branch: "deploy": "gh-pages -b master -d build".

That's all that is necessary. I just tested this a few minutes ago and it seems to be working just fine.

It would be nice if this case could be documented somewhere or even have the recommended script during build changed to this if the user is specifying a GitHub user page, instead of project page.

All 5 comments

There's a workaround here.

  1. Simply change your default branch for your project to something else like source.
  2. Change your deploy script to push to master branch: "deploy": "gh-pages -b master -d build".

That's all that is necessary. I just tested this a few minutes ago and it seems to be working just fine.

It would be nice if this case could be documented somewhere or even have the recommended script during build changed to this if the user is specifying a GitHub user page, instead of project page.

I'm no expert with gh-pages, but if this situation is unique as @aaronlna described I'd be open to a docs modification for this specific case.

Pull request: #3510

Since the PR has been merged I believe this can be closed 馃檪

Thanks @denkristoffer !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Evan-GK picture Evan-GK  路  3Comments

adrice727 picture adrice727  路  3Comments

barcher picture barcher  路  3Comments

JimmyLv picture JimmyLv  路  3Comments

fson picture fson  路  3Comments