89

I've been following the official guide @ pages.github.com

So far I've created the local repo and pushed it to GitHub, but, whatever change I do, I can see it in my repo at GitHub but not in my GitHub page. How is that possible?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
  • Did you push your changes to the `gh-pages` branch? Only that branch will be rendered to the GitHub page… (And that might take up to 10 minutes) – Knut Jul 12 '14 at 12:55
  • Well... I followed the instructions... I think is the main branch... Do i have to create the gh-pages one? –  Jul 12 '14 at 16:10
  • 9
    I don't think you must use `gh-pages`. According to [official document](https://help.github.com/articles/user-organization-and-project-pages/), `gh-pages` is used for project site only, and user site like blog is supposed to use `master`. – dracodoc Oct 20 '15 at 18:39
  • 3
    Also, try opening the site in an incognito window (or clear your cache) - In my case, it was serving a cached version even though the site was updated. – Levi Fuller Jan 09 '18 at 19:11
  • 1
    as Knut already pointed out - it can take some time until the update is rendered... – Stefan Krüger s-light Mar 13 '18 at 10:31
  • 1
    as @LeviFuller pointed out, caching can be a problem. Though in chrome, you can get around caching problems by opening your inspector, then right-clicking on the refresh button, and picking "empty cache and hard reload". – Daniel Paschal Jul 05 '19 at 19:36
  • 2
    Also, as of 7-5-2019, github posts a little green checkmark next to "master" and "gh-pages" branches in the "branch" panel to indicate if it has built the current version. – Daniel Paschal Jul 05 '19 at 19:40

33 Answers33

62

A bit late to the party but I just had this issue and my solution isn't covered by any of the above.

Specifically my issue was the following:

  • I had created a github.pages site with a custom domain.
  • I was pushing commits to the correct GitHub branch but not seeing the updates on the github.pages site.

Solution: The issue turned out to be my browser caching the page (despite my having page caching disabled). To fix it I just cleared my cached data from the past hour and that worked instantly.

To clear the cache data in Chrome go to the Chrome menu then More Tools > Clear Browsing Data.

I don't know what caused the caching, this github.pages/custom domain combo is the only thing that has ever caused it for me.

Josh
  • 1,517
  • 1
  • 13
  • 21
  • it is ironic that with `disable cache` in network tab in dev tools didn't work, but right clicking the reload button and choosing `empty cache and reload` worked – Drdilyor Jul 27 '21 at 17:19
33

Sometimes this happens to me too: after creating and pushing the gh-pages, the GitHub Pages page is missing or not getting updated. Even if I commit more changes to the branch and push it again, it won't update on GitHub pages.

If I remember correctly, I solve this by deleting the branch from the server and pushing it again:

git push origin :gh-pages
git push origin gh-pages

I might have to add some dummy commits and push again to trigger the update, I don't remember exactly...

Franco Rondini
  • 10,841
  • 8
  • 51
  • 77
janos
  • 120,954
  • 29
  • 226
  • 236
  • Thanks for this - it's the only way I could figure out what was wrong. When I re-created the branch, github then notified me that the problem was that a submodule couldn't be updated, so I removed it as a submodule and committed the files it contained instead. But it never gave me any errors before recreating the gh-pages branch, it just wouldn't update. – Matt Browne Nov 02 '14 at 01:50
  • I have having this issue after my first push was successful to gh-pages. Following your instructions fixed it for me. – davetw12 Mar 06 '16 at 18:14
  • 1
    If I try the first command, I get errors like ```error: unable to delete 'gh-pages': remote ref does not exist error: failed to push some refs to``` –  Mar 04 '20 at 22:50
  • for those who got error"`error: unable to delete 'gh-pages': remote ref does not exist error: failed to push some refs to`" may need to go to setting in github and change this Default Branch(left hand side Branch tab), to another branch first. Or create Master branch in github and set it as default. – Sophie cai Sep 03 '20 at 23:54
  • 1
    This fixed the problem in my case. No extra commits were necessary, only: `git push origin :gh-pages`, then wait until the page returns 404, then `git push origin gh-pages`. That is, assuming `gh-pages` is the branch used for GH Pages - which is the default. – Unit03 Jun 20 '22 at 14:18
22

I had the same issue.

The problem was that my website was publishing from the gh-pages branch, but I was pushing my recent changes to the master branch.

Check which branch Github is publishing your website from. In your repository, click on Settings, scroll down the page and there should be a box where you you can change the publishing branch.

It should look like this:

More info is here

Also if you are using a custom domain name, make sure your CNAME file is up to date.

Hope that helps!

ray
  • 5,454
  • 1
  • 18
  • 40
19

I fixed this problem.

you can try to go to the setting page.

I go into the project settings page (.../settings/pages) ,and found Github pages give me some message "some syntax error", I fixed it, and ok.

Thorsten
  • 3
  • 4
Tianyw
  • 199
  • 1
  • 2
17

Try to push empty commit like this

$ git commit --allow-empty -m "Empty commit"

Works like a charm for me every time.

9

To solve this issue

  1. Switch your current Github Pages branch to some other branch and click on Save
  2. Switch back to your desirable Github Pages branch and click on Save.

This will force Github to update your changes.

mechanicious
  • 1,576
  • 2
  • 15
  • 32
  • This one worked nicely for me, after trying many of the solutions above. In your repo go to `Settings > Pages > Source`, and select and save the desired branch. I named mine "switchable" for future use. For creating a new branch on GitHub, go to your repo's code tab, and open the "Switch branches or tags" button, then enter the name for your new branch, and click on the "create..." appearing text. – carloswm85 Nov 29 '21 at 12:21
7

Experienced this problem when a filename contained the word "vendor" ex.:vendor.bundle.20d44fcf5147c6ed68a3.js

Adding an empty file named .nojekyll in the root of the repository fixed the issue.

Jekyll now ignores the vendor and node_modules directories by default https://github.com/blog/2277-what-s-new-in-github-pages-with-jekyll-3-3

Tim Scholten
  • 191
  • 1
  • 5
  • Nowadays you can ask GitHub to use the `docs` subdirectory of the branch to host the page, and I needed a `.nojekyll` in there also, not just the root of the branch. Thanks for this. – Ahmed Fasih Apr 10 '23 at 04:26
7

I am a novice and please allow me to answer with tears. Please go to settings at your repository, scroll down to enter image description here to check WHETHER THERE IS A PROBLEM with your current webpage. If there is a problem, your site WILL NOT BE UPDATED. I think it's a protection mechanism or something.

This morning I deleted and moved some of the files in repository, I have updated many times and it still remains on previous version, even I checked the index.html has indeed updated. Later I shut down the whole repository and started new one, inserting items one by one, but still met the problem. I tried new branch like gh-pages, I think it is not necessary for a beginner like me. Later I checked my settings and found the notification, I deleted the problematic files and it worked instantly. Were I knew the problem I would not have been so stupid to shut down it forever. I miss my old git records. Guess every lesson takes a price, Github is no exception.

6

Press ctrl+F5 to re-download cached content.

buddemat
  • 4,552
  • 14
  • 29
  • 49
entroook
  • 61
  • 1
  • 1
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 17 '21 at 05:00
5

Try to disable GitHub pages, and enable it after a few minutes. I tried. This works. But It takes some time to update and re-enable GitHub Pages.

TheMisir
  • 4,083
  • 1
  • 27
  • 37
4

I tried Janos' answer but it didn't work for me.

I made a slight change to my index.html file (something insignificant) and pushed to the gh-pages branch again. I tried opening the page in a different browser and it worked. My original browser updated the page too although I don't think it's a browser cache issue.

I rebased master with gh-pages locally and pushed that as well, not sure if that makes any difference.

Community
  • 1
  • 1
Srini
  • 1,626
  • 2
  • 15
  • 25
3

I recently had an issue where my github pages hosted site wasn't updating from an old branch push in master. I was able to see the new changes by going to domain.com. (the dot at the end is important), and also hard refreshing would show the new changes, but with a regular refresh, it would show the old site and the old JS files too.

My problem seemed to only be in Chrome, which is where I was developing the site. For full disclosure, the old changes were in React and hosted in Netlify. The new changes that I was trying to get to push and display were static files hosted in github pages.

THE FIX (in Chrome): devtools > Application > clear site data (button).

3

This answer is for those who have created their app with create-react-app.

It took me days to finally find the answer for react-gh-pages not updating. I hope the following answer helps as it did for me. It is a combination of multiple answers that I have researched over:

The main and most common reason is your browsers caching feature. In order to disable it for every rendering of your index.html,

  1. Add this snippet in your index.html file under the public folder.

<meta http-equiv='cache-control' content='no-cache'> 
<meta http-equiv='expires' content='0'> 
<meta http-equiv='pragma' content='no-cache'>
  1. Push any new changes to the master or main branch(not to the origin gh-pages).
  2. By now your master branch is updated.
  3. Now run: git push origin :gh-pages. This will delete the gh-pages branch.
  4. Run: npm run deploy. This will re-build your app and re-create gh-pages branch with updated content.
  5. Now go the settings section on the top-right side of your app repo page. Scroll down to the bottom. Under Github Pages section, under source, there is branch section. Change that to your master branch or main. Keep the root folder as it is.
  6. Go to your site and you will see a Readme file. It may take some time. After a minute or so change the branch back to gh-pages. After a minute visit your site and it should be updated by now.

I hope this helps! Let me know if it worked for you as well in the comment section, cheers!

Dorji Tshering
  • 893
  • 1
  • 6
  • 15
2

If your GitHub pages repo is private AND you have recently downgraded to GitHub Free, this might apply:

Your subscription, GitHub Free, does not support GitHub Pages sites for private repositories. After we introduced free private repositories in January, we found a limited number of sites connected to private repositories were mistakenly left active. If you’d like to keep updating this site, you can make its repository public or upgrade to GitHub Pro. You can also unpublish it below. This site is using a custom CNAME: Secure your domain name before unpublishing this site.

Yiannis
  • 155
  • 1
  • 13
2

In my case it related to an issue in my config file. This showed up on Settings -> Pages. enter image description here

Jonathan
  • 13,947
  • 17
  • 94
  • 123
2

If your page was online, but after update no changes visible:

1: Change repository to private

2: Change back to public

3: Enable "GitHub Page" function again

Pastuh
  • 376
  • 2
  • 12
2

For those who find solutions above not useful try this:

  • delete "build" directory on your local machine
  • run "npm run deploy" Deleting directory helped me, it will reflect changes on github pages branch, then wait a minute, if you still dont see any changes, try clearing cache or visit your page in incognito

Worked for me.

kacperj513
  • 31
  • 5
1

Here is what worked for me:

First Step (update your master):

git add . 

git status                # to see the changes to be committed

git commit -m "comments"

git push origin master

Second Step (Update gh-pages):

git-checkout gh-pages     # going to the gh-pages branch

git rebase master         # sync gh-pages with master 

git push origin gh-pages  # commit changes to gh-pages

git checkout master       # return to the master 
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
coder
  • 93
  • 1
  • 8
  • 2
    Just a warning: this may work for your project structure, but in some configurations this can really screw you up. Not everybody's `gh-pages` branch is related to their `master` branch like this; in fact, Github suggests creating `gh-pages` as an orphan branch if you aren't using Jekyll. – meustrus Nov 03 '16 at 17:51
  • When I try to checkout to gh-pages, I get this: ```error: pathspec 'gh-pages' did not match any file(s) known to git.``` –  Mar 04 '20 at 23:04
  • https://stackoverflow.com/questions/60528076/how-can-i-update-my-github-pages-website/60528147?noredirect=1#comment107088099_60528147 –  Mar 04 '20 at 23:05
  • git-checkout gh-pages is not valid.. you mean git checkout gh-pages – Fergus Mar 15 '23 at 23:23
1

I had the same problem everything is up to date in my repository but it still wasn't loading to my github page, so without making any further changes, I tried to add, commit and pull.

I fixed it with another git commit, and git pull again. Now the changes are loaded to my git.

Alexander Wigmore
  • 3,157
  • 4
  • 38
  • 60
Riya Abraham
  • 151
  • 1
  • 6
1

The easiest way:

Settings -> Braches -> choose "gh-pages" -> UPDATE.

Take mine as example

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
Lena
  • 87
  • 1
  • 7
  • 1
    In my case, I don't see the github-pages drop-down as seen in your pic. Mine just says unless you specify a different branch. The default branch is set to master. To change this setting, add another branch. –  Mar 04 '20 at 22:59
1

In my case, it helped to run:

npm run deploy

I did it after pushing the master branch to GitHub. I needed to wait a bit until the changes were visible on my page. But it did work without changing any settings.

  • it was working for me but there also need to change in settings as well – Ashish Kamble May 11 '20 at 09:54
  • This worked for me, *exactly* as described above. You can also verify that the deployment was successful, by looking at the 'Actions' tab in Github. – Peter Feb 22 '22 at 19:49
  • As mentioned above, you can use an alternative method to verify the deployment: Under the 'Code' tab, select the "gh-pages" branch - then look for a green checkmark and time stamp. – Peter Feb 22 '22 at 20:03
1

In case this helps someone else...

For me the issue was the content in the branch was being updated, but the filenames did not change, so browser was retrieving cached content.

I'm using Angular CLI with angular-cli-ghpages. Setting the configuration to production appends hashes after each file in the build forcing the browser to retrieve the new content.

sample deploy script:

ng build --configuration=production --base-href \"<repo-name>\" && ngh

If you don't want a production build, you can also specify output hashing in other build configurations in angular.json

Steve
  • 1,326
  • 14
  • 21
1

If you're using the gh-pages command you may need to delete the gh-pages cache at node_modules/gh-pages/.cache

doubledherin
  • 340
  • 1
  • 3
  • 7
1

The issue is being caused because of the browser caching the page. Open the git link in incognito mode.

1

I reflect my changes in my deployed GitHub repository after committing locally, by renaming my gh-pages branch to master and unpublishing my GitHub Page, and then re-name the branch to gh-pages and then publish it again; then it works.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Daud Ahmad
  • 11
  • 1
1

A couple have mentioned looking for error messages in Settings->Pages, but a better place to look is the stdout of the jekyll build workflow under the About tab. In either case, an error message of any sort is best to have in hand before starting on any of the other 26 answers given above.

J B
  • 348
  • 1
  • 6
0

After making changes in your script, go down to the commit changes section. There you'll find one input box and one text-area. As you all know filling those boxes is not mandatory, but they are there for a reason. So, next time before clicking on the commit changes button give this a try >> make sure that you write something in the first input box (you can leave the text-area empty), and what you write is different from what you wrote for your last commit for the same file. In this way github will be able to distinguish between the current script and the updated one, and the change should be reflected almost instantly.

Hope that helps.

Subham Saha
  • 1
  • 1
  • 2
0

The problem is caused due to browser caching the page. Disable browser caching with meta HTML tags. Add the following in _layouts/default.html

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

WARNING: After this any browser supporting Cache-Control will not store any of your cookies or files.

Alex
  • 37
  • 2
0

This can happen for various reasons. My issue was that the condition that was tested for during the deploy step didn't match the triggering branch. I had used another script as a model, and it had been trigger from pushes to main. I changed the on: push: at the top to my desired branch, but didn't notice the conditional, so it stayed referencing main

name: Deploy stuff to Pages

on:
  push:
    branches:
      - other-branch # <---- this is my trigger branch

jobs:
  build:
    name: Build

    steps:
      # build steps here

  deploy:
    name: Deploy
    needs: build
    if: github.ref == 'refs/heads/other-branch' # <---- needs to match, was previously 'main'

    steps:
        # deploy steps here
    ```
Artemis Prime
  • 99
  • 1
  • 5
0

Perhaps it's because of errors in one of your codes. That was my case, I saw a red "X" at the left of the commit ID. It won't update your page until the commit has no errors. It has to be a green check at the left of your commit. If you have a red "X" click on it and see the errors you have. solve them and the page will update after you commit without errors.

I show the image below depicting what you need to see (a green check, no errors):

commit with no errors

edier88
  • 71
  • 2
0

in github pages: in that place we choose the name of our branch ex."main" github give us another option this is "None" choose it and save. after that repeat choose your branch again ex."main" and save wait for afew seconed and update your page it is work with me.for explain

Debug100
  • 1
  • 1
  • Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? **If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient.** Can you kindly [edit] your answer to offer an explanation? – Jeremy Caney Aug 17 '23 at 02:32
  • i just tried and it was work with me it is easy direct and fast for me ,so i just share it. – Debug100 Aug 27 '23 at 07:58
-1

Just clear browser's cache. ctrl + shift + r for Chrome, as example

  • 5
    Please first read the other answers before you post, you probably then noticed this has nothing to do with page refreshes and the answer you give is wrong. Also have a look at the tour: stackoverflow.com/tour and how to write a good answer: stackoverflow.com/help/how-to-answer – nijm Jul 10 '18 at 20:08
-1

Nothing to worry, to Update your git react code rebuild code by using command

npm run deploy

react code will updated to gh-pages

Kiran
  • 1
  • 1