254

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?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Jonathan de M.
  • 9,721
  • 8
  • 47
  • 72
  • 6
    I assume you followed the [documentation](http://pages.github.com/)? Have you got an email?- From the 404: "We'll send you an email when your page has been built. It may take up to ten minutes until your page is available." – David Cain Jul 20 '12 at 10:22
  • I tried the generated page, and it was working fine. Then I have remove gh-pages branch and rebuild it with my custom html. I'm waiting since at least one hour now – Jonathan de M. Jul 20 '12 at 10:25
  • I contacted the github support, and they said it was a problem on their side, and they fixed it manually – Jonathan de M. Oct 15 '12 at 05:41
  • 1
    please try with `https`. if it's working then after few time it will for with `http` – Rohit Suthar Oct 07 '15 at 13:00
  • 1
    the https trick worked for me in another way. I have everything right and the setting page said the site is published, gave me the right url. However it keep giving 404. I changed the url to http, it worked, then https worked too. Looks like the http site need to be accessed to "activate" it first. – dracodoc Jan 19 '18 at 15:27
  • 2
    For me it started working after 10-20 mins. Its takes time. So be patient. – MechaCode Sep 25 '18 at 09:09
  • https://stackoverflow.com/questions/53797321/react-github-pages-deploy-err-aborted-404-not-found/67376311#67376311 – KushalSeth May 04 '21 at 16:42

45 Answers45

267

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.

Arnaud
  • 17,268
  • 9
  • 65
  • 83
  • 2
    I was using the npm package angular-cli-ghpages and what I did was add a space to my index.html file, reran the command "npx ngh" which pushed a new commit for me acheiving the same glorious results. Thanks, this had me stumped and your answer inspired me to do this. – Patrick Graham Aug 15 '18 at 19:41
  • if you don't want to use the command line you can just edit your README.md direclty from the web interface. – Christophe Le Besnerais Feb 21 '19 at 14:51
  • 2
    It may also be a problem with Github itself. [This page](https://www.githubstatus.com/) tells you the status of Github. I had the same problem, and no fix worked. The status page said "degraded performance", and I just had to wait for the servers to be fully functional again. – Hendrikto Mar 12 '19 at 19:23
  • Good point @Hendrikto, I added a reference to your comment in the answer. – Arnaud Jan 11 '20 at 12:41
  • thank you surprisingly nobody has mentioned this anywhere and for some reason, this answer is not chosen as the right answer. I think it needs to be documented somewhere. Can you also provide a reference to the Github doc perhaps? @Arnaud – Novin Shahroudi Jan 11 '21 at 22:18
  • I did this, and now I no longer see a 404, but (perhaps even worse), now I see "ERR_TOO_MANY_REDIRECTS". Huh? – starmandeluxe Apr 20 '22 at 08:13
  • 1
    @starmandeluxe Probably a problem with your DNS setup. – Arnaud Apr 20 '22 at 08:52
126

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
eQ19
  • 9,880
  • 3
  • 65
  • 77
120

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

Ky -
  • 30,724
  • 51
  • 192
  • 308
  • 13
    .nojekyll is a must if you're not using Jekyll, docs here: https://github.com/blog/572-bypassing-jekyll-on-github-pages – Claudiu Constantin Sep 28 '17 at 13:03
  • 4
    Thank you for this, I have emailed github and asked them to update their guide at [pages.github.com](https://pages.github.com/) (which doesn't mention the .nojekyll file) – sunyata Oct 11 '17 at 16:58
  • 1
    Thanks! It was required for Vue app, too bad it is not mentioned in vue-cli deploy guide. – Ondřej Ševčík Jun 28 '19 at 05:20
  • 1
    this fixed it for me. My user site was originally working without it but stopped working. You can just add a file online and commit it there too. I did this, refreshed and it instantly worked. – bot19 May 24 '20 at 02:23
  • @OndřejŠevčík Is vue-cli specifically about GitHub page deployment? If no, then it is not really their role to warn about footguns on all possible hostings – reducing activity Nov 15 '21 at 13:34
  • 1
    @bot19 yeah, it was part of vue-cli deploy that talked about deploying to GitHub Pages – Ondřej Ševčík Nov 16 '21 at 14:49
  • 1
    Was using Astro which now uses a `_astro` sub-directory to serve bundles. Thanks OP! – VRG May 06 '23 at 14:08
62

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

  2. I deleted the gh-pages branch on local

    git branch -D gh-pages

  3. I reinitialized git

    git init

  4. I recreated the branch on local

    git branch gh-pages

  5. I pushed the gh-pages branch to github

    git push origin gh-pages

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

Jonathan de M.
  • 9,721
  • 8
  • 47
  • 72
46

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

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 13
    I was getting 404 Not Found and having tried all eighteen of the other solutions suggested in answers here I documented my attempts in a duplicate question: [Very simple HTML resulting in 404 Not Found on GitHub Pages](https://stackoverflow.com/q/55314621/575530). Chris's 19th answer was the one that fixed it for me. GitHub Pages is a great service, it is a shame the documentation is so poor. – dumbledad Mar 24 '19 at 10:13
  • 4
    Just choosing a scheme still is not enough, you also need to create a new commit on the `gh-pages` branch to trigger an update afterwards! – sschuberth Sep 30 '19 at 11:26
23

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.

Clay
  • 10,885
  • 5
  • 47
  • 44
  • I put a whitespace in "index.html", committed and pushed changes. Nothing happened. Removed whitespace from the filename, committed and pushed changes again and it worked! Thanks. – Nahiyan May 15 '17 at 17:31
  • also note that github pages use a small caching window (10 minutes at the time of writing: `Cache-Control:max-age=600`). so you may also have to wait on that cache window to expire or force refresh your browser. – Clay Jun 27 '17 at 18:29
  • 5
    Why mess with the whitespace? Just push an empty commit with `--allow-empty`. – Hendrikto Feb 05 '18 at 13:01
20

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/

Timeless
  • 7,338
  • 9
  • 60
  • 94
20

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?

Rivalus
  • 1,052
  • 9
  • 10
  • The question mark trick works for webpages, but doesn't seem to work for directories that autoredirect to index.html – Jason S Feb 23 '23 at 19:09
18

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
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
Rashomon
  • 5,962
  • 4
  • 29
  • 67
13

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

JefClaes
  • 3,275
  • 21
  • 23
6

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

João Nunes
  • 3,751
  • 31
  • 32
  • This one and choosing a Jekyll theme (even though I don't want to use Jekyll) is what fixed mine. Also, I had originally had my repo set to private. I guess that doesn't work with Github Pages. – Azurespot Jan 07 '21 at 22:14
  • 1
    This did the trick, although it messed my github page url real good. It's incredible they don't mention a single time this need of turning github pages ON in their tutorial page https://pages.github.com. – darksoulsong Dec 31 '21 at 19:12
5

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.

dracodoc
  • 2,603
  • 1
  • 23
  • 33
4

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

<!DOCTYPE html>
4

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

enter image description here

Jöcker
  • 5,281
  • 2
  • 38
  • 44
4

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.

Aaditya Ura
  • 12,007
  • 7
  • 50
  • 88
3

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!

3

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"
      },
Joe Gasewicz
  • 1,252
  • 15
  • 20
3

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.

adrisons
  • 3,443
  • 3
  • 32
  • 48
2

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")

PhysRex
  • 184
  • 2
  • 7
2

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
Has AlTaiar
  • 4,052
  • 2
  • 36
  • 37
2

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.

Parzh from Ukraine
  • 7,999
  • 3
  • 34
  • 65
CarpeDiemKopi
  • 316
  • 3
  • 13
2

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.

030
  • 10,842
  • 12
  • 78
  • 123
2

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.

ssi-anik
  • 2,998
  • 3
  • 23
  • 52
2

In my case it was that I had recently set up a custom domain for GitHub pages, but GitHub had forgotten my custom domain under (repo)<name>.github.io / Settings / Pages.

I added the custom domain again and then it immediately started working.

EDIT: I forgot to update this at the time, but now that I got an upvote I am adding more info.

The real reason that the domain was forgotten is that GitHub adds a commit on top of your repo with a special file called CNAME that contains the information. If you remove that file by mistake (rebase or force-push) then the domain mapping is also removed.

Erik Živković
  • 4,867
  • 2
  • 35
  • 53
1

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.

strongwillow
  • 328
  • 2
  • 13
1

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.

Ahmad Awais
  • 33,440
  • 5
  • 74
  • 56
1

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.

chrismarx
  • 11,488
  • 9
  • 84
  • 97
  • 1
    This helps. My project was **private at first** and in that state I pushed project to Github pages and I get 404 (ofc). After switching from `gh-pages` to `master`, and then back from `master` to `gh-pages` everything was fine and application start to work. – zrna Jun 08 '20 at 10:43
1

Your GitHub Pages is available at http://roine.github.io/p1 instead of http://roine.github.com/p1.

By the way, you can fix your project's description.

TimTIM Wong
  • 788
  • 5
  • 16
0

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

twenk11k
  • 557
  • 5
  • 17
0

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.

Parag Deuskar
  • 87
  • 1
  • 9
0

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.

Glenn
  • 8,932
  • 2
  • 41
  • 54
0

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

> <title>
> 
> <script>

Fixed, after removing space

> <title>
> <script>
Pastuh
  • 376
  • 2
  • 12
  • This is probably just equivalent to causing a site rebuild as in https://stackoverflow.com/a/45907768/124703 – Kenyon Jan 10 '21 at 23:20
0

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.

faken
  • 6,572
  • 4
  • 27
  • 28
0

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

Santosh Kadam
  • 1,265
  • 14
  • 14
0

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

Tri
  • 2,722
  • 5
  • 36
  • 65
0

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.

Leonard
  • 29
  • 5
0

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.

Gustavo Maximo
  • 4,426
  • 3
  • 17
  • 26
0

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

xq nie
  • 41
  • 5
0

The following operations helped me:

webpack build:

Webpack output.publicPath

publicPath: './'

vite build:

vite base

base: './'
xq nie
  • 41
  • 5
0

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

davidgw
  • 11
  • 1
0

If you're using a framework like Angular, it could be that you have to set the base href path: https://stackoverflow.com/a/54409380/1585161

Using Angular CLI: ng build --baseHref="/users/"

Or more generally: <base href="/users/">

Also be sure that your image assets start with ./assets not /assets

Connor
  • 670
  • 3
  • 9
  • 29
0

Today bumped into the same issue. In my case I was adding script as module, which resulted in HTTP 404 trying to fetch the file when deployed with Github Pages. I had to switch my bundler to make it work.

in the index.html file

DID NOT WORK:
<script type="module" src="./index.4b5c177027.js"></script>

WORKS:
<script src="./index.4b5c177027.js"></script>

Best,

0

In my case, I had first created a site without jekyll and had a .nojekyll file. I then changed my mind and created a site with jekyll (ignoring the non-empty repository warning and using --force). Then I had just forgotten to delete the .nojekyll file. Deleting it fixed the issue.

Rohit
  • 7,449
  • 9
  • 45
  • 55
0

if you are reviving an old website, go to actions -> pages-build-deployment -> pages build and deployment -> Re-run all jobs

Varun Garg
  • 2,464
  • 23
  • 37
0

For Angular 16 I did:

npm i angular-cli-ghpages --save-dev

Then ran these 2 commands:

ng build --base-href "https://danday74.github.io/pods-prototype/"
npx angular-cli-ghpages --dir=dist/pods

Where:

danday74 is YOUR_USERNAME

pods-prototype is YOUR_GITHUB_REPO_NAME

dist/pods is YOUR_LOCAL_FOLDER where the build files are located

Then I could access my site (after a 10 sec delay) at:

https://danday74.github.io/pods-prototype

danday74
  • 52,471
  • 49
  • 232
  • 283