如何设置 GitHub 页面以在不同位置查找 index.html?

How to set up GitHub Pages to look for index.html in a different location?

只需设置我的 GitHub Pages 网站,据我所知,GitHub Pages 将在父目录中查找 index.html(即,如果我的存储库位于 username.github.io,它将在 username.github.io/index.html).

中寻找 index.html

如果它在那里找不到 index.html,它会在页面上呈现我的 README.md。

index.html 文件必须放在那里,还是有办法告诉 Pages 在 username.github.io/src/index.html 中查找该文件?

没有

您需要更改站点源以更改 Jekyll 读取文件的目录,但这是您无法在 GitHub 页面中更改的配置设置:

https://help.github.com/articles/configuring-jekyll/#configuration-settings-you-cannot-change

但是,您可以在 GitHub 存储库的设置中将源更改为 docs 文件夹。

参见

您可以试试这个:在根目录下创建一个虚拟 index.html 文件,然后插入这行代码并为其指定正确的路径。

index.html

<meta http-equiv="refresh" content="0; url=https://yourname.github.io/myapplication/frontend/public/index.html" />

根据this gist, by cobyism, you can use subtrees (not to be confused with the subtree merge strategy):

git subtree push --prefix <your-path> origin gh-pages

来自 git-subtree 文档 git's source code:

Subtrees allow subprojects to be included within a subdirectory of the main project, optionally including the subproject's entire history.

For example, you could include the source code for a library as a subdirectory of your application.