This repository demonstrates how to deploy a React app using GitHub Pages. GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.
GitHub Pages is a service provided by GitHub to host static websites directly from a repository. It supports custom domains, HTTPS, and can run the files through a build process before deployment.
- Install Node.js and npm: Make sure you have Node.js and npm installed on your computer.
- Create a React App: Use Create React App to set up your project.
npx create-react-app horror-app cd horror-app
- Install gh-pages: Install the
gh-pages
package as a dev dependency.npm install gh-pages --save-dev
- Add homepage to package.json: Add the following line to your
package.json
file."homepage": "https://<your-username>.github.io/horror-app"
- Add deploy scripts to package.json: Add the following scripts to the
scripts
section of yourpackage.json
."scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build" }
- Initialize a Git repository (if you haven't already):
git init git remote add origin https://github.com/<your-username>/horror-app.git git add . git commit -m "Initial commit" git push -u origin master
- Deploy your app:
npm run deploy
- Navigate to the repository settings: Go to your repository on GitHub, click on the
Settings
tab. - GitHub Pages settings:
- Under the
Pages
section, ensure the source is set to thegh-pages
branch. - Save the settings.
- Under the
Your React app should now be live at https://<your-username>.github.io/horror-app
.