【问题标题】:Github pages returns readme file instead of index.html. Can't host my react projectGithub 页面返回自述文件而不是 index.html。无法托管我的反应项目
【发布时间】:2017-10-10 15:01:06
【问题描述】:

我在 gh-pages 上托管我的 react 项目时遇到问题。 我在 github 上有我的仓库 ----> GitHub repo 我的页面返回自述文件而不是 indx.html (public/index.html)。 ---> My Page

如果我的 react 应用程序正常工作,我应该如何处理我的页面?

【问题讨论】:

标签: github github-pages


【解决方案1】:

根据我的经验,这只是一个延迟问题。当我最初提交 index.html(在 repo 的根目录中)时,myorg.github.io 继续为 README.md 提供服务。几个小时后,我返回并再次尝试 - 瞧,我的 index.html 已送达。由于我不在的时间,我无法猜测github页面更新需要多长时间。

【讨论】:

  • 感谢您的回答!我正要应用另一个答案提出的更改,但现在只等了大约 5 分钟后,我的 README.md 是http://my_username.github.io/my_project 的服务器。
【解决方案2】:

我在 readme.md 中添加了前面的部分,它解决了问题。

---
permalink: /index.html
---

在此之后它显示 index.html 而不是自述文件。我发现这个解决方案也有助于自定义 404 页面。 https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/

【讨论】:

    【解决方案3】:

    是的,问题在于您如何部署站点,您应该将目标 index.html 部署到 gh-pages 看看这个:

    https://medium.freecodecamp.com/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089

    它对如何将 React 应用程序部署到 github 页面提供了详细且非常好的解释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 2021-11-01
      • 2018-12-08
      • 2019-04-26
      • 1970-01-01
      • 2017-12-21
      • 2016-04-24
      相关资源
      最近更新 更多