Skip to content

Instantly share code, notes, and snippets.

@Charlie-robin
Last active May 16, 2022 08:13
Show Gist options
  • Save Charlie-robin/469adc5bd02e01abed74fd1d4871f677 to your computer and use it in GitHub Desktop.
Save Charlie-robin/469adc5bd02e01abed74fd1d4871f677 to your computer and use it in GitHub Desktop.
React project to GitHub Pages

Host a React project on Github pages

Make sure you have the repository on GitHub.

  1. Add github Pages as a dev dependency to the project.
npm install gh-pages --save-dev
  1. Add a "homepage" key to the package.json. The value will be a string, with your GitHub username and project repository in the URL.
"homepage":"http://USERNAME.github.io/REPONAME",

The USERNAME will need to be all lowercase

The REPONAME will need to be all lowercase, you may need to rename your repository

  1. Add a deploy script to the package.json. Keep the other scripts.
"scripts": {
  "deploy": "gh-pages -d build",
}
  1. Run
npm run build
npm run deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment