My own personal website hosted with GitHub Pages.
To deploy a ReactJs project to GitHub pages,
- Create a repo named <your_username>.github.io
- Clone the repo locally
- Add your ReactJs project under the repo
- Add gh-pages as a dev dependency by running
npm install gh-pages --save-dev
- In
package.json
, add- under
scripts
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
- near
"name"
and"version"
"homepage": "<your_url>",
- under
- Run in the terminal
npm run deploy
- it will build the app
- create a new branch called
gh-pages
- deploy it in the new branch
- You need to change the default branch used for deployment
- in your repo, under
Settings
->Pages
->Branch
-> change branch togh-pages
.
- in your repo, under
After all the above you should be good to go.