Skip to content

Commit 770fdf4

Browse files
aaronlnaTimer
authored andcommitted
Update User Guide with deploying to GitHub User pages (#3510)
1 parent 733ba3a commit 770fdf4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/react-scripts/template/README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -2012,12 +2012,18 @@ For more information see [Add Firebase to your JavaScript Project](https://fireb
20122012
**The step below is important!**<br>
20132013
**If you skip it, your app will not deploy correctly.**
20142014

2015-
Open your `package.json` and add a `homepage` field:
2015+
Open your `package.json` and add a `homepage` field for your project:
20162016

2017-
```js
2017+
```json
20182018
"homepage": "https://myusername.github.io/my-app",
20192019
```
20202020

2021+
or for a GitHub user page:
2022+
2023+
```json
2024+
"homepage": "https://myusername.github.io",
2025+
```
2026+
20212027
Create React App uses the `homepage` field to determine the root URL in the built HTML file.
20222028

20232029
#### 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`:
20482054

20492055
The `predeploy` script will run automatically before `deploy` is run.
20502056

2057+
If you are deploying to a GitHub user page instead of a project page you'll need to make two
2058+
additional modifications:
2059+
2060+
1. First, change your repository's source branch to be any branch other than **master**.
2061+
1. Additionally, tweak your `package.json` scripts to push deployments to **master**:
2062+
```diff
2063+
"scripts": {
2064+
"predeploy": "npm run build",
2065+
- "deploy": "gh-pages -d build",
2066+
+ "deploy": "gh-pages -b master -d build",
2067+
```
2068+
20512069
#### Step 3: Deploy the site by running `npm run deploy`
20522070

20532071
Then run:

0 commit comments

Comments
 (0)