假设我在我的 username.github.io 上放了一个 index.html,我可以通过 url http://username.github.io
访问它
现在考虑 2 个相互矛盾的情况
- 比如,我有一个名为
repo1
的存储库,其中激活了 gh-pages。所以,它应该在http://username.github.io/repo1
上可用
- 我还在
username.github.io
位置放置了一个名为repo1
的文件夹,里面有一个 index.html。
这是我的问题
现在,如果我从浏览器访问 url http://username.github.io/repo1
将提供 1 或 2 中的哪一个?更重要的是为什么?
最佳答案
我用我的 github 存储库 sumanbarick.github.io
测试了它。
发现在名称冲突的情况下,存储库(github pages)将获得优先权。
测试 1:http://sumanbarick.github.io/test/
- 首先,我创建了一个名为
test
的存储库,其中包含一个 index.html。创建分支 gh-pages。我尝试了 urlhttp://sumanbarick.github.io/test/
并得到了页面 index.html。 - 然后我在
sumanbarick.github.io
repo 中创建了一个名为test
的文件夹和一个 index.html 文件夹 - 我再次点击了 url。但他仍然从 repo 中得到了 index.html
测试 2:第 1 个定义是否具有第 1 个优先级?
- 这次我在
sumanbarick.github.io
仓库中创建了一个名为test2
的文件夹和一个 index.html。我尝试了 urlhttp://sumanbarick.github.io/test2/
并从文件夹 test2 中获取了页面 index.html - 但是一旦我用 gh-pages 创建了 repo
test2
,url 的结果就偏向于 repo 的索引页
所以,这是部分答案。现在我们知道了,
问。哪个优先?
一个。 repo 协议(protocol)(转到上面提到的 url 并亲自查看)。
问。为什么?
一个。我仍然对 WHY 这部分感到好奇。让我们看看其他人怎么说。
关于html - 在名称冲突的情况下,哪个将获得 "github pages"和 "directory kept at root"之间的优先级以及原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37314702/