Github页面返回自述文件而不是index.html。无法托管我的React项目

Luk*_*kas 4 github github-pages

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

我应如何使用我的React应用程序正确处理我的页面?

小智 8

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


Gri*_*ead 5

我已将重要事项添加到readme.md并解决了该问题。

---
permalink: /index.html
---
Run Code Online (Sandbox Code Playgroud)

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


sla*_*lal 2

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

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

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