From 552d21f9a9032bed10833fb18e892b31df60561b Mon Sep 17 00:00:00 2001 From: Aaron Lamb Date: Mon, 27 Nov 2017 13:28:42 -0800 Subject: [PATCH] Update User Guide with deploying to GitHub User pages (#3510) --- template/README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/template/README.md b/template/README.md index c4ee34dcc2e..c8bd3911fdc 100644 --- a/template/README.md +++ b/template/README.md @@ -2012,12 +2012,18 @@ For more information see [Add Firebase to your JavaScript Project](https://fireb **The step below is important!**
**If you skip it, your app will not deploy correctly.** -Open your `package.json` and add a `homepage` field: +Open your `package.json` and add a `homepage` field for your project: -```js +```json "homepage": "https://myusername.github.io/my-app", ``` +or for a GitHub user page: + +```json + "homepage": "https://myusername.github.io", +``` + Create React App uses the `homepage` field to determine the root URL in the built HTML file. #### Step 2: Install `gh-pages` and add `deploy` to `scripts` in `package.json` @@ -2048,6 +2054,18 @@ Add the following scripts in your `package.json`: The `predeploy` script will run automatically before `deploy` is run. +If you are deploying to a GitHub user page instead of a project page you'll need to make two +additional modifications: + +1. First, change your repository's source branch to be any branch other than **master**. +1. Additionally, tweak your `package.json` scripts to push deployments to **master**: +```diff + "scripts": { + "predeploy": "npm run build", +- "deploy": "gh-pages -d build", ++ "deploy": "gh-pages -b master -d build", +``` + #### Step 3: Deploy the site by running `npm run deploy` Then run: