GitHub页面没有更新

147
我在使用 GitHub Pages 时遇到了奇怪的问题。我将一个新提交推送到我的个人页面 maltzj.github.io,但新的文章没有显示出来。当我在本地执行服务器时,一篇文章位于 localhost:4000/posts/the-price-of-inconsistent-code/。然而,当我转到 http://maltzj.github.io/posts/the-price-of-inconsistent-code 时,出现了404错误。我还添加了一个新文件,应该位于 http://maltz.github.io/test.html,但这也导致了404错误。
所有内容在本地都构建和运行正常。我的Git仓库是最新的,并且GitHub状态页面上没有关于构建问题的信息,所以我不知道该怎么办?我如何让我的页面更新我添加的新内容?
参考资料,支持我的页面的存储库位于http://github.com/maltzj/maltzj.github.io

"您正在尝试发布一个页面吗?可能需要最多十分钟才能使您的页面可用。" - Mmmh mmh
4
我知道,但是提交的出版物已经在仓库中超过5个小时了,但并没有显示出来。个人页面通过主分支部署,对吗? - Jonathan
6
对我来说,这是因为浏览器使用了缓存数据(旧样式),所以我打开了另一个浏览器。 - mohammedgqudah
对我来说,这是浏览器的问题。打开火狐浏览器后,它就正常工作了。 - dogonaroof
2
使用Ctrl+Shift+R来强制刷新页面对我很有帮助,因为这样可以清除浏览器最初使用的缓存数据。 - AbtabM
2
你可以在一个空提交上触发重建。git commit --allow-empty -m "Trigger rebuild" 然后 git push。参考:https://dev59.com/CWgu5IYBdhLWcg3wGjdF#45907768 - Jovial Joe Jayarson
48个回答

1
在 Github 项目页面的右下角有一个环境部分,如下所示:

github pages environments

点击 github-pages 将显示部署的当前状态。

在新提交后,工作流可能需要一段时间才能完成,并显示为 Pending 状态。

显然,即使状态恢复为 Active,实际更改也可能需要几分钟才能实时看到,因此项目页面上的状态更改与实际内容刷新以及可能发生的 github 后端缓存刷新之间存在延迟。

从项目 设置 > 页面 顶部,您还可以查看最后一次部署的状态和时间,例如:

由 user2030 在 33 分钟前部署

将鼠标悬停在分钟上将显示完整的时间戳。


0
如果有人手动从头创建了gh-pages分支,问题在于您需要一个名为params.json的文件才能使其正常工作。
以下是该文件的示例:
{
  "name": "nameOfProyect",
  "tagline": "name of proyect",
  "body": "### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:\r\n\r\n```\r\n$ cd your_repo_root\/repo_name\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `<a>` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at https:\/\/help.github.com\/pages or contact support@github.com and we\u2019ll help you sort it out.\r\n",
  "google": "",
  "note": "Don't delete this file! It's used internally to help with page regeneration."
}

0

我尝试了几乎所有的答案,尝试编辑index.html等。

我的错误在于,我没有构建和部署,所以我在我的npm脚本中添加了构建和部署步骤。如果您正在使用React应用程序,则直接复制粘贴此代码即可。

这些是我的构建脚本:

  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -b master -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

当你完成更改并且你的应用程序使用npm start运行良好,请按照以下步骤:

步骤1:运行命令npm run build

如果一切顺利,您将收到消息:构建文件夹已准备好部署

enter image description here

步骤2:运行命令npm run deploy

您将会收到如下信息:已发布

enter image description here

步骤3:刷新您的应用程序:例如https://kushalseth.github.io。这不是必须的,但请提交并推送所有更改以供参考。

附注:如果您遇到404等问题,请查看此答案:React Github Pages Deploy ERR_ABORTED 404 (Not Found)


0

我使用了git commit -am "blah",但忘记只有我的_data/navigation.yaml中的导航链接被更改了,而我创建的新的page.md没有添加到工作树中,因此当我点击导航树中的链接时显示404错误。

检查,再检查!


0

前往

设置 / GitHub Pages / 源

并将其更改为

无(禁用GitHub Pages)

让系统保存您的更改。之后,再次更改

设置 / GitHub Pages / 源

回到原始值。


0
在我的情况下,我有另一个文件与页面相同的permalink,但内容没有刷新。请注意这一点。

0

我已经认真阅读了所有43个答案。两次。令人惊讶的是,没有一个答案告诉你该怎么做,而我只是通过在我的repo的github仪表板上随机点击不同的东西偶然发现了这一点。不要点击设置。点击操作。在那里,您将看到当jekyll尝试构建网页时实际发生的工作流程。您可以单击工作流程,它将显示一个红色的“x”标记,因为它失败了,并查看完整的stdout文本输出。包括像我这样的信息性错误消息: /usr/local/bundle/gems/jekyll-3.9.2/lib/jekyll/theme.rb:84:in `rescue in gemspec': The slate theme could not be found. (Jekyll::Errors::MissingDependencyException)


0

在我的情况中,有两个问题(一个是“PEBCAK”,然后是更有效的一个)。

我在GitHub中设置了两个电子邮件地址,并检查非主要电子邮件以获取构建错误消息(管理电子邮件:登录GitHub,单击右上方的用户菜单,选择“设置”,然后从左侧菜单中选择“电子邮件” - 构建错误消息将发送到设置的主电子邮件)。

一旦我看到了错误消息,我发现我在我的_config.yaml中添加了一个描述,包括一个“:”字符,因为这是用于分隔key,value对的字符,它阻止了该站点的构建。


0

我曾经在一个非常基础的项目中遇到了同样的问题。通过进行硬刷新 [ctrl + shift + r],我解决了这个问题。

我的项目只是使用了纯HTML、CSS和JavaScript。上述方法可能对于高级项目有效也可能无效。


0

我曾经遇到过同样的问题。在我的情况下,我用一个新头像替换了旧头像。之前的头像扩展名是“jpeg”,而新的头像扩展名是“jpg”,所以我将文件重命名为与之前相同的扩展名。我等了一天,但更改没有出现。我注意到构建失败了。我将文件重命名为正确的扩展名,并更改了相应的HTML文件。构建只用了2分钟就准备好了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接