Can I create more than one repository for github pages?

試著忘記壹切 提交于 2019-11-28 15:14:36
Stephen Jennings

You can have one site per GitHub repository. Repositories other than "username.github.io" will be published at http://username.github.io/REPONAME. Those repositories will publish whatever you push to the "gh-pages" branch.

A better description is available in the GitHub Pages documentation.

(since April 2013, all username.github.com are now username.github.io)

No you are not limited, it is possible to have multiple GitHub Pages sites within one account. Create another GitHub repository and push your site files to the gh-pages branch. This would result in the site being hosted at tshepang.github.io/repo-name

Now, push another file "CNAME" to the same repository and branch and fill it with movies.tshepang.net. Log in to your DNS host and add the CNAME to point to "tshepang.github.io" (just like the original site).

This would allow you to have seemingly two different sites on different domains. This would not work for having two or more sub-domains within github.io itself.

There is a possibility to host multiple pages within the same repository having sub-pages if you are fine with code duplication.

The latest version of my website is hosted on http://username.github.io/REPONAME This is a screenshot of the structure of my root repository where I host the latest version of my website:

Inside folder "2.4.0" I can host a previous version of the same page ,which is then reachable at: http://username.github.io/REPONAME/2.4.0 This is the structure of the folder 2.4.0:

Using this methodology of sub-pages within a main page, you can host multiple sub-pages within one main page.

I found a workaround if you don't want to make separate repositories for your different sites but just want to host them. In your io repo, create an index.html file on your master branch that acts as a table of contents linking to your other sites(subDirectories) index.html files. The username.github.io master branch seems to be the landing page that enables the hosting, so if it doesn't see an index file linking out to your separate projects, it won't register your subdirectories. After this all you need is the URL to whatever project you want to view. The io basically behaves like a giant single website with all your separate projects on it. Of course, if you would rather have separate repositories, gh-pages is the way to go.

You can register a organization. Then create a repository(xxx.github.io) to deploy it to Github Pages. xxx is the organization name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!