Skip to content

Commit

Permalink
Update User Guide with deploying to GitHub User pages (facebook#3510)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlna authored and Pavel Zhytko committed Jul 10, 2018
1 parent a3a997a commit 660f465
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2012,12 +2012,18 @@ For more information see [Add Firebase to your JavaScript Project](https://fireb
**The step below is important!**<br>
**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`
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 660f465

Please sign in to comment.