I’ve been struggling with getting my various portfolio projects deployed lately. However, I do believe I’ve got deployment to Github Pages down pat. Thankfully it’s really straightforward, so I’ll keep the to-do list brief.
- Install the gh-pages NPM package.
npm install --save-dev gh-pages
- Update your repository’s package.json with these lines:
"homepage": "https://[your Github username].github.io/[your Github repository]"
and under “scripts”:"deploy" : "npm run build&&gh-pages -d build"
- Build the app. The build command will likely be one of these:
npm run build
react-scripts build
webpack
- Deploy the app.
npm run deploy
- Over on your Github repository’s settings page, under Github Pages, ensure ‘source’ is set to ‘gh-pages branch’.