60

I'm trying to host my webpages into Github pages but for some reason it seems to only show my Readme file.

GitHub repo: https://github.com/InquisitiveDev2016/InquisitiveDev2016.github.io

Website:

https://inquisitivedev2016.github.io/

Rookie
  • 675
  • 1
  • 7
  • 9
  • 1
    I was having the same problem when I first created my index.html in the root of my project, and this answer helped me to realize I simply needed to wait a few minutes and try again: https://stackoverflow.com/a/53678354/2604813 – Marcus Feb 27 '20 at 21:30

14 Answers14

36

GitHub Pages is doing what it is designed to do: hosting the contents of that repository.

The root of the question asker's repository only contained a single file (README.md). So there isn't an easy way to navigate to the other pages, e.g. repo/website/webpage.html.

Consider moving your web content into the root of your repository and renaming your default page to index.md or index.html, depending what type of file it is. (By convention the default page of most websites is called index.html, and this is what GitHub Pages will show by default if it exists.)

treckstar
  • 1,956
  • 5
  • 21
  • 26
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 3
    In case it might help someone...I had to move all my build files including index.html to the root folder to get it working – Marvel Moe Feb 23 '21 at 21:43
19

Github gives you multiple choices where it takes it sources from. By default its the root of the master branch, which will use the README.md in case there is no index.html.

But you can also switch to the docs/ folder in your repository settings. With that you can put the index.html under the docs/ folder.

See enter image description here

oae
  • 1,513
  • 1
  • 17
  • 23
11

In my case, I had to choose the branch gh-pages/root in Pages settings on GitHub.

fadingbeat
  • 355
  • 3
  • 16
6

I had a similar situation when deploying a static React app from create-react-app (so index.html was in /public instead of root) with gh-pages npm package.

I had to select a gh-pages as a branch and /docs as a folder at GitHub Project -> Settings -> Pages -> Folder/Branch dropdowns. It wasn't intuitive since I didn't have /docs anywhere in my project files, but I'm glad that it eventually worked!

lomboboo
  • 1,221
  • 1
  • 12
  • 27
Iryna
  • 61
  • 1
  • 3
4

Create an index.html in the root and insert the line

<meta http-equiv="Refresh" content="2; url=public/index.html">

Or so it worked for me with a Vue CLI project I had this trouble with.

bretonio
  • 49
  • 2
4

if you want to access to index.html, try to write https://your-github-deploy-address/index.html

so just add '/index.html' at the end of the address! (this is how I solved my case)

Mira Weller
  • 2,406
  • 22
  • 27
bonlim
  • 163
  • 9
2

For me, this solution solves the issue:https://github.com/gitname/react-gh-pages

Open the package.json file, add two properties as below:

  • Add a homepage property in this format*: https://{username}.github.io/{repo-name}
  • For a project site, that's the format. For a user site, the format is: https://{username}.github.io. You can read more about the homepage property in the "GitHub Pages" section of the create-react-app documentation.

      {
        "name": "my-app",
        "version": "0.1.0",
      + "homepage": "https://gitname.github.io/react-gh-pages",
        "private": true,
    
  • Add a predeploy property and a deploy property to the scripts object in :

      "scripts": {
      +   "predeploy": "npm run build",
      +   "deploy": "gh-pages -d build",
          "start": "react-scripts start",
          "build": "react-scripts build",
    
Murphy Xue
  • 21
  • 1
1

The simplest solution to overcome this is put the index.html file in the outermost folder along with the readme.md

Deb
  • 355
  • 2
  • 9
1

Please change the HTML file to index.html. This simple thing had me struggling for 6 hours to find this. My HTML name before was base.html; this shows the read me file only. After changing to index.html the file opened without any problems.

andrbrue
  • 721
  • 6
  • 15
karthi
  • 11
  • 1
0

The steps to resolve this issue is from best practice is to go the your project folder. You should change what ever you named your root or initial page to index.html as mentioned above. Then open your project in git bash on your system, perform your normal git steps like,

  • git add
  • git commit -m " change to index.html"
  • git push origin master {depending on what you named your root branch}

Then go to settings and there you go (wow wow) after one or two refresh, your site will be live

Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21
0

For me, the problem was the docs folder was moved to .gitignore automatically. You have to delete docs from .gitignore, commit and push.

Mislav Sagovac
  • 185
  • 1
  • 8
0

Change the GitHub Pages source to gh-pages with folder as /(root)

HarshitChopra
  • 41
  • 1
  • 3
  • I'd say this answer has been repeated multiple times already in this question, so it may be considered a duplicate. – treckstar May 28 '22 at 13:49
  • 1
    Please up-vote those answers/comments, as the accepted answer of this post is not correct/working – HarshitChopra May 28 '22 at 14:27
  • Yes I absolutely try and up vote as much as I can, was simply just making an observation. I would disagree that the accepted answer isn't correct, the concept still applies, just the link is no longer working. I did put in an edit to remove that broken link as well. – treckstar May 28 '22 at 16:23
0

Github is looking into root folder and displaying readme.md file .Append SiteUrl given by github with the path to index.html file . so github pages start rendering your index.html file.

Where to get site Url

In my case my complete Url will be https://userName.github.io/RepoName/src/index.html

Shankar
  • 1
  • 1
-1

To summer up, if your repository does not have an Index.html it will show the ReadMe file. Thus in order to correct it all you need to do is add an index.html or index.md file to your folder and use that as main. From there all the others will be access through a link on this page. Similarly to a webpage.