How to fix HTTP 404 on Github Pages?

GithubGithub Pages

Github Problem Overview


Here is my GitHub repository on the gh-pages branch. Everything looks good, I have my index.html, my CSS, JS and pictures folders.

But when I access http://roine.github.com/p1 I get HTTP 404 not found.

Any explanation and solution?

Github Solutions


Solution 1 - Github

I had just one commit with all my files. I pushed an empty commit, refreshed the page and it worked.

git commit --allow-empty -m "Trigger rebuild"
git push

If this doesn't work, as @Hendrikto pointed out in the comments, check out the Github status page and make sure GitHub Pages are operational.

Solution 2 - Github

I did all the tricks on my repo to fix page 404 on Github Page (https://eq19.github.io/) but it kept 404'ing.

Finaly found that my browser hardly keep the 10 minutes cache before it up on the web.

Just add /index.html into the end of URL then it showed up and solved the case.

https://username.github.io/{repoName}/index.html

Solution 3 - Github

In my case, I had folders whose names started with _ (like _css and _js), which GH Pages ignores as per Jekyll processing rules. If you don't use Jekyll, the workaround is to place a file named .nojekyll in the root directory. Otherwise, you can remove the underscores from these folders

Solution 4 - Github

Four months ago I have contacted the support and they told me it was a problem on their side, they have temporarily fix it (for the current commit).

Today I tried again

  1. I deleted the gh-pages branch on github

git push origin --delete gh-pages

  1. I deleted the gh-pages branch on local

git branch -D gh-pages

  1. I reinitialized git

    git init

  2. I recreated the branch on local

    git branch gh-pages

  3. I pushed the gh-pages branch to github

    git push origin gh-pages

Works fine, I can finally update my files on the page.

Solution 5 - Github

If you haven't already, choose a Jekyll theme in your GitHub Pages settings tab. Apparently this is required even if you're not using Jekyll for your Pages site.

GitHub settings screenshot

Solution 6 - Github

I had the same issue after forking a repo with a gh-pages branch. I was able to fix by simply pushing a new commit (just whitespace in index.html) to my fork's gh-pages branch.

Solution 7 - Github

In my case on 8/Aug/2017

  1. if your user page is https://github.com/mgravell, you repo name must be mgravell.github.io

  2. under root, create a file index.html

  3. under root, create a folder docs, create a file CNAME under docs (note: NO extension like .txt, make sure your file system shows extension)

  4. gh-pages branch is optional, master branch is sufficient

more: check official docs here: https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/

Solution 8 - Github

Just wait about ten minutes to one hour. If it still doesn't work, contact github. Usually it's the problem at their end. But, if you're in a hurry, you can try to open by adding "?" question mark at the end of URL. It force query to search for the resource. Like this:

http://roine.github.com/p1?

Solution 9 - Github

In my case the browser had a previous cached version of my app. To avoid getting the cached version, access you url using a random query string:

https://{{your-username}}.github.io/{{your-repository}}?randomquery

Solution 10 - Github

My pages also kept 404'ing. Contacted support, and they pointed out that the url is case sensitive; solved my issue.

Solution 11 - Github

in my case i had to go to project settings and enable the github pages. The default is off

Solution 12 - Github

If you saw 404 even everything looks right, try switching https/http.

The original question has the url wrong, usually you can check repo settings and found the correct url for generated site.

However I have everything set up correctly, and the setting page said it's published, then I still saw 404.

Thanks for the comment of @Rohit Suthar (though that comment was to use https), I changed the url to http and it worked, then https worked too.

Solution 13 - Github

Add the following in the beginning of the index.html file

<!DOCTYPE html>

Solution 14 - Github

In my case in react was necessary to select the gh-pages branch:

enter image description here

Solution 15 - Github

I was facing the same issue, after trying most of the methods mentioned above I couldn't get the solution. In my case the issue of because of Github changing the name of master to main branch.

Go to Setting -> go to GitHub Pages section and change the branch to main:

enter image description here

to

enter image description here

Save it and select a theme, and the website is live.

Solution 16 - Github

If you are sure that your structure is correct, just push an empty commit or update the index.html file with some space, it works!

Solution 17 - Github

I had this exact problem with typedocs. The README.md worked but none of the actual docs generated by my doc strings displayed, I just got a 404 Github Pages screen.

To fix this, just place a empty file in your /docs directory (or wherever you generate your docs) & call it .nojekyll

To confirm, your file structure should now look like:

./docs/.nojekyll  # plus all your generated docs

Push this up to your remote Github repo and your links etc should work now.

Also make sure you have selected in your Github settings:

Settings -> Github Pages -> Source -> master brach /docs folder

Depending on your doc framework, you probably have to recreate this file each time you update your docs, this is an example of using typedocs & creating the .nojekyll file each time in a package.json file:

# package.json

      "scripts": {
        "typedoc": "typedoc --out docs src && touch docs/.nojekyll"
      },

Solution 18 - Github

The solution for me was to set right the homepage in package.json.

My project name is monsters-rolodex and I am publishing from console gh-pages -d build.

"homepage": "https://github.com/monsters-rolodex", > The project was built assuming it is hosted at /monsters-rolodex/.

Before it didn't work because in the homepage url I included my github username.

Solution 19 - Github

I got the site to work by deleting the "username.github.io" folder on my computer going through the steps again, including changing the index/html file.

My mistake (I think) is that i initially cloned "https://github.com/username/username.github.io**.git**" instead of https://github.com/username/username.github.io (no ".git")

Solution 20 - Github

In my case, all the suggestions above were correct. I had most pages working except few that were returning 404 even though the markdown files are there and they seemed correct. Here is what fixed it for me on these pages:

  • On one page, there were a few special characters that are not part of UTF-8 and I think that's why GitHub pages was not able to render them. Updating/removing these char and pushing a new commit fixed it.
  • On another page, I found that there were apostrophes ' surrounding the title, I removed them and the page content started showing fine

Solution 21 - Github

For some reason, the deployment of the GitHub pages stopped working today (2020-may-05). Previously I did not have any html, only md files. I tried to create an index.html and it published the page immediately. After removal of index.html, the publication keeps working.

Solution 22 - Github

I was following this YT video. So, when I ran the command in my terminal, it pushed the code to gh-pages branch already. Then I pushed to the master branch. It was giving me 404 error.

Then I swapped the branch to master and then again reverted to gh-pages and now the error is gone. It's pointing to the index.html even if it's not in the URL.

Solution 23 - Github

I bound my domain before this problem appeared. I committed and pushed the branch gh-pages and it solved my problem. New commits force jekyll to rebuild your pages.

Solution 24 - Github

In my case, the URL was quite long. So, I guess there is a limit. I put it to my custom subdomain and it worked.

Solution 25 - Github

On a private repo, when I first added and pushed my gh-pages branch to github, the settings for github pages automatically changed to indicate that the gh-pages branch would be published, but there no green or blue bar with the github.io url and no custom domain options.

It wasn't until I switched the source to master and quickly switched the source back to gh-pages that it actually updated with the green bar that contains the published url.

Solution 26 - Github

Another variant of this error:

I set up my first Github page after a tutorial but gave the file readme.md a - from my perspective - more meaningful name: welcome.md.

That was a fatal mistake:

> We’ll use your README file as the site’s index if you don’t have an > index.md (or index.html), not dissimilar from when you browse to a > repository on GitHub.

from Publishing with GitHub Pages, now as easy as 1, 2, 3

I was then able to access my website page using the published at link specified under Repository / Settings / GitHub Pages followed by welcome.html or shorter welcome.

Solution 27 - Github

Go to settings section of your repository and choose master branch at the Source section and click save button after that refresh the page and you will be able to see the link of your page!.

Solution 28 - Github

I faced this problem (404) too and the root cause was my file was named INDEX.md. I was developing on Windows and my local Jekyll site worked (since Windows treats file names case insensitive by default). When pushed to Github, it didn't work. Once I renamed the INDEX.md to index.md, things worked well.

Solution 29 - Github

Yet another scenario:

  • using an Organization Page (not a Project page) that has a repository named <orgname>.github.io
  • source documents as markup in master branch (asciidoc)
  • Travis CI pulling source doc files from master and pushing generated html files to gh-pages branch

The gh-pages branch is updated with the generated html pages. The GitHub Environment tab provides the link to the organization page. Clicking it results in a 404.

According to https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/

> User and Organization Pages that have this type of repository name are > only published from the master branch

If I understand this correctly, GitHub Pages will not be published from the gh-pages branch if you are creating a User or Organization site rather than a Project site.

I renamed my repo to make it a Project site rather than Organization site and then the gh-pages branch was published as expected.

Solution 30 - Github

I had same issue.. Very strange issue.. My HTML was with space after title

> <title>
> 
> <script>

Fixed, after removing space

> <title>
> <script>

Solution 31 - Github

Also, GitHub pages doesn't currently support Git LFS. As such, if you have images (or other binary assets) in GitHub pages committed with Git LFS, you'll get 404 not found for those files.

This will be quite common for documentation generated with Doxygen or similar tool.

The solution in this case is to simply not commit those files with Git LFS.

Solution 32 - Github

In my case my repository was private. Make repository public and go through all steps again.

Solution 33 - Github

I also faced this issue, my pages getting 404. And then I added README.md on my repository, and the 404 was gone.

Solution 34 - Github

I faced the same issue(404 on a newly set up GitHub pages website) yesterday. I tried many methods such as switching a new theme etc. But it seems that it still did not work on my case. I finally figured it out by switching the branch of GitHub pages website to another branch, click save. Wait for a while and switch it back again. Then the problem was suddenly solved.

Solution 35 - Github

I had to rename my repo to a random name then rename it back to it's original name for it to work.

Seems like it might be a GH Pages bug.

Solution 36 - Github

I used umijs to package and deploy the project to github pages. The following operations helped me:

    1. In 13 line, add base: my-project-name;
    1. Redeploy gh-pages 

A little guess: github pages need to be deployed to a non-root directory

Solution 37 - Github

The following operations helped me:

webpack build:

Webpack output.publicPath

publicPath: './'

vite build:

vite base

base: './'

Solution 38 - Github

For me the key was recognising that you could see error messages from the build process by going to the 'Actions' tab in your github repo. Clicking on the latest 'pages build and deployment' workflow revealed the error message that was preventing publication (simple bug in my _config.yml).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonathan de M.View Question on Stackoverflow
Solution 1 - GithubArnaudView Answer on Stackoverflow
Solution 2 - GithubeQ19View Answer on Stackoverflow
Solution 3 - GithubKy.View Answer on Stackoverflow
Solution 4 - GithubJonathan de M.View Answer on Stackoverflow
Solution 5 - GithubChrisView Answer on Stackoverflow
Solution 6 - GithubClayView Answer on Stackoverflow
Solution 7 - GithubTimelessView Answer on Stackoverflow
Solution 8 - GithubRivalusView Answer on Stackoverflow
Solution 9 - GithubRashomonView Answer on Stackoverflow
Solution 10 - GithubJefClaesView Answer on Stackoverflow
Solution 11 - GithubJoão NunesView Answer on Stackoverflow
Solution 12 - GithubdracodocView Answer on Stackoverflow
Solution 13 - GithubAnirban MukherjeeView Answer on Stackoverflow
Solution 14 - GithubJöckerView Answer on Stackoverflow
Solution 15 - GithubAaditya UraView Answer on Stackoverflow
Solution 16 - GithubAhad DastbelarakiView Answer on Stackoverflow
Solution 17 - GithubJoe GasewiczView Answer on Stackoverflow
Solution 18 - GithubadrisonsView Answer on Stackoverflow
Solution 19 - GithubPhysRexView Answer on Stackoverflow
Solution 20 - GithubHas AlTaiarView Answer on Stackoverflow
Solution 21 - Github030View Answer on Stackoverflow
Solution 22 - Githubssi-anikView Answer on Stackoverflow
Solution 23 - GithubstrongwillowView Answer on Stackoverflow
Solution 24 - GithubAhmad AwaisView Answer on Stackoverflow
Solution 25 - GithubchrismarxView Answer on Stackoverflow
Solution 26 - GithubCarpeDiemKopiView Answer on Stackoverflow
Solution 27 - Githubtwenk11kView Answer on Stackoverflow
Solution 28 - GithubParag DeuskarView Answer on Stackoverflow
Solution 29 - GithubGlennView Answer on Stackoverflow
Solution 30 - GithubPastuhView Answer on Stackoverflow
Solution 31 - GithubfakenView Answer on Stackoverflow
Solution 32 - GithubSantosh KadamView Answer on Stackoverflow
Solution 33 - GithubTriView Answer on Stackoverflow
Solution 34 - GithubLeonardView Answer on Stackoverflow
Solution 35 - GithubGustavo MaximoView Answer on Stackoverflow
Solution 36 - Githubxq nieView Answer on Stackoverflow
Solution 37 - Githubxq nieView Answer on Stackoverflow
Solution 38 - GithubdavidgwView Answer on Stackoverflow