Deploy on GitHub Pages

Damaris Göbel
Aug 11, 2022
  1. Install package
npm install gh-pages — save-dev

2. Add a homepage property in the package.json and deploy scripts

Go to your package.json and write

“homepage”: “https://{username}.github.io/{repo-name}"

Under “scripts” add two lines:

+ “predeploy”: “npm run build”,+ “deploy”: “gh-pages -d build”,

3. Connect your project with a GitHub repository

git remote add origin https://github.com/{username}/{repo-name}.git

4. Deploy the app to GitHub Pages

npm run deploy

That will cause the predeploy and deploy scripts defined in package.json to run.

5. Push code to GitHub repo

git add .git commit -m “Configure React app for deployment to GitHub Pages”git push origin master

It takes some time.

6. Check

Under Pages in your settings you have the branch gh-pages chosen with root

7. Voila look at your beautiful app! :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Damaris Göbel
Damaris Göbel

Written by Damaris Göbel

I like to do crazy things with CSS & JavaScript. My brain occasionally runs out of memory so I need to write down my thoughts.

No responses yet

Write a response