Pratik Kumar
Pratik Kumar

Reputation: 69

only readme.md is showing on github pages

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

Upvotes: 0

Views: 6431

Answers (4)

Ali H. Kudeir
Ali H. Kudeir

Reputation: 1054

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.

Upvotes: 1

Ori Naftaly
Ori Naftaly

Reputation: 1

I had the same problem.

  1. make sure that to change source from master branch to gh-pages branch.
  2. If you don't have a README.md file, create one at the gh-pages branch.

this should work!

Upvotes: 0

Nick Brady
Nick Brady

Reputation: 6572

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.

  1. Set your source on the GitHub repository. I.e.

    Your GitHub Pages site is currently being built from the gh-pages branch.

  2. Add to your scripts in package.json the deploy and predeploy

  "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
  },
  1. Deploy your app. yarn deploy assuming you made the script as above.

  2. 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.

enter image description here 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.

Upvotes: 0

Midhun G S
Midhun G S

Reputation: 957

  1. Remove all files from repo
  2. Build your project
  3. Add all files are directories inside build to the repo

Hope it works !!

Upvotes: 0

Related Questions