I have the following code in my package.json – which is usually sufficient to deploy a react app to github pages. This app is slightly different as I use an index.html file in the public folder – does anyone know of a solution to deploy this to github pages?
https://github.com/simharuk2021/reduxcart/tree/main/public
I have already tried playing about with the url but makes no difference, I just get the standard react app readme page displayed post deployment.
"name": "reduxcart",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.2.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-scripts": "5.0.1",
"reactstrap": "^9.1.10",
"redux": "^4.2.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^5.0.0"
},
"homepage": "https://simharuk2021.github.io/reduxcart/public/"
}```
[1]: https://i.stack.imgur.com/BNSsY.png
2
Answers
Here is the github pages screenshot
githubpages setup
You are using main branch for deploying, github pages require you to use gh-pages branch, it should be created automatically after you use command:
npm run deploy
. Here’s the reference: https://blog.logrocket.com/deploying-react-apps-github-pages/