72

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?

Nikita Fedyashev
  • 16,963
  • 11
  • 45
  • 76
  • 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
  • 2
    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
  • 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
  • 1
    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

26 Answers26

42

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,135
  • 11
  • 19
  • 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
29

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,421
  • 8
  • 45
  • 73
janos
  • 115,756
  • 24
  • 210
  • 226
  • 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
20

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,289
  • 1
  • 15
  • 37
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
15

Try to push empty commit like this

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

Works like a charm for me every time.

7

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,526
  • 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
6

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
  • 181
  • 1
  • 5
5

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.

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,588
  • 2
  • 14
  • 24
4

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
  • 3,615
  • 1
  • 23
  • 35
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!

3

Press ctrl+F5 to re-download cached content.

buddemat
  • 3,262
  • 10
  • 15
  • 39
entroook
  • 31
  • 1
  • 1
    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
2

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

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,067
  • 4
  • 34
  • 58
Riya Abraham
  • 151
  • 1
  • 6
1

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

1

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
  • 145
  • 2
  • 11
0

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
  • 35,848
  • 27
  • 79
  • 88
coder
  • 63
  • 1
  • 7
  • 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
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 easiest way:

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

Take mine as example

Adrita Sharma
  • 19,704
  • 10
  • 55
  • 71
Lena
  • 11
  • 1
  • 4
  • 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
0

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
0

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,228
  • 13
  • 19
0

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

doubledherin
  • 300
  • 1
  • 3
  • 7
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.

0

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
  • 8,684
  • 19
  • 37
  • 59
-1

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

  • 4
    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
-3

Well all you have to do is to run the following command:

npm run deploy

It will automatically update the gh-pages