Html 我可以为 github 页面创建多个存储库吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15563685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I create more than one repository for github pages?
提问by Akshat Jiwan Sharma
I created a repositoryfor hosting a blog on github.Is there any way that I can create more to host multiple blogs?Am I limited to just one repository for hosting(since username.github.comcan only be used once?)
我创建了一个用于在 github 上托管博客的存储库。有什么方法可以创建更多来托管多个博客?我是否仅限于一个托管存储库(因为username.github.com只能使用一次?)
回答by Stephen Jennings
You can have one site published to https://<username>.github.io
by publishing to the master branch of a repository named “username.github.io” (substituting your actual username).
您可以https://<username>.github.io
通过发布到名为“username.github.io”(替换您的实际用户名)的存储库的 master 分支来发布一个站点。
You can also have an additional site per GitHub project published to https://<username>.github.io/<project>
. Project sites will publish whatever you push to the "gh-pages" branch by default, but you can change the publishing source in the repository settings.
您还可以将每个 GitHub 项目的附加站点发布到https://<username>.github.io/<project>
. 默认情况下,项目站点将发布您推送到“gh-pages”分支的任何内容,但您可以在存储库设置中更改发布源。
A better description is available in the GitHub Pages documentation, including options for using custom domain names.
GitHub Pages 文档 中提供了更好的描述,包括使用自定义域名的选项。
(since April 2013, all username.github.com
are now username.github.io
)
(自 2013 年 4 月起,username.github.com
现在都是username.github.io
)
回答by hopper
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
不,您不受限制,一个帐户中可以拥有多个 GitHub Pages 站点。创建另一个 GitHub 存储库并将您的站点文件推送到 gh-pages 分支。这将导致该站点托管在 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).
现在,将另一个文件“CNAME”推送到同一个存储库和分支,并用movies.tshepang.net 填充它。登录到您的 DNS 主机并添加 CNAME 以指向“tshepang.github.io”(就像原始站点一样)。
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.
这将允许您在不同的域上拥有看似两个不同的站点。这不适用于在 github.io 本身中有两个或多个子域。
回答by phil
There is a possibility to host multiple pages within the same repository having sub-pagesif you are fine with code duplication.
如果您对代码重复没有问题,则可以在具有子页面的同一存储库中托管多个页面。
The latest version of my website is hosted on http://username.github.io/REPONAMEThis is a screenshot of the structure of my root repository where I host the latest version of my website:
我网站的最新版本托管在http://username.github.io/REPONAME这是我托管网站最新版本的根存储库结构的屏幕截图:
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.0This is the structure of the folder 2.4.0:
在文件夹“2.4.0”内,我可以托管同一页面的先前版本,然后可以在以下位置访问:http: //username.github.io/REPONAME/2.4.0这是文件夹 2.4.0 的结构:
Using this methodology of sub-pages within a main page, you can host multiple sub-pages within one main page.
使用主页内子页面的这种方法,您可以在一个主页内托管多个子页面。
回答by Rahul Soshte
You can register a organization. Then create a repository(xxx.github.io) to deploy it to Github Pages. xxx is the organization name.
您可以注册一个组织。然后创建一个存储库(xxx.github.io)将其部署到 Github Pages。xxx 是组织名称。
回答by Vipin
Today I created another site and rather than creating branch gh-pages I have configured the master branch in a repository setting --> GitHub pages section select Source as master (or any other branch you want). You will get site link in the same section, in my screen shot I have removed site link.
今天我创建了另一个站点,而不是创建分支 gh-pages 我在存储库设置中配置了 master 分支 --> GitHub pages 部分选择 Source as master (或任何其他你想要的分支)。您将在同一部分获得站点链接,在我的屏幕截图中,我已删除站点链接。
回答by Andre Holguin
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.
如果您不想为不同的站点创建单独的存储库而只想托管它们,我找到了一种解决方法。在您的 io 存储库中,在您的 master 分支上创建一个 index.html 文件,该文件充当链接到其他站点(子目录)index.html 文件的目录。username.github.io 主分支似乎是启用托管的登录页面,因此如果它没有看到链接到您的单独项目的索引文件,它就不会注册您的子目录。在此之后,您所需要的只是您想要查看的任何项目的 URL。io 基本上就像一个巨大的单一网站,上面有你所有的独立项目。当然,如果您更愿意拥有单独的存储库,那么 gh-pages 是不错的选择。