Skip to content
kitiya edited this page Mar 21, 2020 · 9 revisions
git checkout master
git pull origin master
git merge test
git push origin master

Step 1: Add homepage to package.json

Create React App uses the homepage field to determine the root URL in the built HTML file.

"homepage": "https://myusername.github.io/my-app",

Step 2: Install gh-pages and add deploy to scripts in package.json

Now, whenever you run npm run build, you will see a cheat sheet with instructions on how to deploy to GitHub Pages.

To publish it at https://myusername.github.io/my-app, run:

npm install --save gh-pages

Add the following scripts in your package.json:

"scripts": {
+   "predeploy": "npm run build",
+   "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",

The predeploy script will run automatically before deploy is run.

Step 3: Deploy the site by running npm run deploy

npm run deploy

Step 4: For a project page, ensure your project’s settings use gh-pages

Finally, make sure GitHub Pages option in your GitHub project settings (in the source section) is set to use the gh-pages branch:

Clone this wiki locally