This is a react js app.I want index.html (which is in public folder by default) as my root folder or any link to navigate index.html here is my github page :-https://impratikprtk.github.io/almostthere/ and this is my repository :- https://github.com/impratikprtk/almostthere
-
1The simplest solution is to follow the official guide. https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#github-pages – Håken Lid Jul 03 '18 at 11:59
-
1Github pages will serve either from the `/docs` folder on master branch (__not__ `/public`) or from the root folder of either `master` branch a branch called `gh-pages`. https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/ – Håken Lid Jul 03 '18 at 12:02
4 Answers
In my case, I had to make the active branch to be the gh-pages branch, and also from the settings' options tab make the Source branch to also be gh-pages branch.

- 756
- 2
- 9
- 19
- Remove all files from repo
- Build your project
- Add all files are directories inside build to the repo
Hope it works !!

- 906
- 9
- 22
I found this answer here to be much more helpful: GitHub pages only showing ReadMe file? . My site was showing the readme file because I had my source as master, and when I thought I was deploying for master, I was actually deploying to my remote with the gh-pages
branch which turned out to be much cleaner anyways. When it was reading from master, it didn't see an index so it showed the README.md
file by default.
I was deploying from a create react app. I didn't realize that running gh-pages -d build
actually created the gh-pages
branch on your remote (GitHub) and pushed to it exactly as needed automatically. That said, all I had to do to fix this problem was to change my source for pages to be the gh-pages
branch.
Set your source on the GitHub repository. I.e.
Your GitHub Pages site is currently being built from the gh-pages branch.
Add to your scripts in
package.json
thedeploy
andpredeploy
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn build", // <--- this and
"deploy": "gh-pages -d build" // <--- that
},
Deploy your app.
yarn deploy
assuming you made the script as above.Log into GitHub, go to your repository, and check out the
gh-pages
branch that should have been created for you. It takes a couple minutes to update on the actual website, so this is a good first place to check to see that the deployment is working.
Note.. The documentations mention an initial deploy.. but I can see when I run
yarn deploy
that it actually runs yarn build
without me doing it first.. so I don't seem to need to run the "predeploy". Would love a comment here about that.

- 6,084
- 1
- 46
- 71
I had the same problem.
- make sure that to change source from master branch to gh-pages branch.
- If you don't have a README.md file, create one at the gh-pages branch.
this should work!