GitHub Pages 优先级

4

假设我在GitHub上有以下仓库:

caffinatedmonkey (user)
│
├── caffinatedmonkey.github.io
│   └── tree
│       └── master
│           └── foo
│               └── index.html
└── foo
    └── tree
        ├── master
        └── gh-pages
            └── index.html

如果我访问 caffinatedmonkey.github.io/foo,哪个页面会显示?项目页面 https://github.com/caffinatedmonkey/foo/tree/gh-pages/index.html 还是用户页面 https://github.com/caffinatedmonkey/caffinatedmonkey.github.io/tree/master/foo/index.html 优先?

2个回答

3

用户页面具有优先权,但不是基于每个URL的。即使URL不发生冲突,拥有用户页面也会禁用项目页面。

为了解决这个问题,您可以将项目页面的gh-pages分支设置为user.github.io仓库的子模块。

cd user.github.io
git submodule add -b gh-pages https://github.com/user/project.git
git submodule update
git commit -m 'Added submodule for project'
git push

1
我通过复制问题中的存储库结构来设置测试。当我访问caffinatedmonkey.github.io/foo时,我被带到用户的foo页面,https://github.com/caffinatedmonkey/caffinatedmonkey.github.io/tree/master/foo/index.html
用户页面优先。

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