GitHub项目页面的自定义域 [英] Custom domain for GitHub project pages
问题描述
我在我的一个 http://中有一个 gh-pages
分支github.com repos。如果我去 http://myuser.github.com/myrepo
I have a gh-pages
branch in one of my http://github.com repos. The GitHub project pages works fine if I go to http://myuser.github.com/myrepo
我想要设置一个自定义域(myexample.com),它将提供这个项目页面。我想要 myexample.com
和 www.myexample.com
提供这些项目
I want to setup a custom domain (myexample.com) that will serve up this project pages. I want both myexample.com
and www.myexample.com
to serve up these project pages.
GitHub页面帮助表示在您的DNS中创建A记录和CNAME记录。 A记录是有道理的,但我不知道在我的DNS中做什么CNAME记录。
GitHub pages help says to make an A record and a CNAME record in your DNS. The A record makes sense, but I do not know what CNAME record to make in my DNS.
gh-pages
docs说要为'charlie.github.com'(一个用户页面存储库)创建一个 CNAME
记录。我没有用户页面存储库 - 我只有一个项目存储库和一个 gh-pages
分支,我想用于 myexample.com
和 www.myexample.com
。
The gh-pages
docs say to make a CNAME
record for 'charlie.github.com' which is a user page repository. I do not have a user page repository - I only have a project repository and a gh-pages
branch that I want to use for myexample.com
and www.myexample.com
.
我需要做一个用户页面存储库,所以我可以使用我的项目页面www.myexample.com和myexample.com?
我会尝试,但我想以确保这可以正常工作,因为我已经有www.myexample.com直播,并且不想犯错误。
I would just try it, but I want to make sure this will work as I already have www.myexample.com live and don't want to make a mistake.
我通过电子邮件发送GitHub支持,他们的回复是
I emailed GitHub support and their response was
据我所知,你不能同时指向同一个gh页面。
You can't have both point to the same gh-pages as far as I know.
我很难相信他们只会支持项目页面的A记录。
I find it hard to believe they would only support A records for project pages.
有没有人成功完成过?
推荐答案
所以我想出来了。 James McLaughlin 给了我需要的微调。
So I figured it out. James McLaughlin gave me the nudge I needed.
要设置自定义域为gh页面项目页面repo处理www.yourdomain.com和yourdomain.com(假设您已经在您的回购站已经有一个gh页面分支):
To Setup a custom domain for a gh-pages Project Pages repo that handles www.yourdomain.com and yourdomain.com (assumes you already have a gh-pages branch on your repo):
- 从您的项目回购,gh-pages分支。创建一个CNAME文件,内容是
yourdomain.com
。提交然后推送。 - 在您的DNS管理器中,设置两个
cname
记录。一个为根顶(@),一个为www。两者都指向YOURusername.github.io
。如果您的DNS提供商不支持根顶点(@)上的ALIAS
记录,只需创建指向A
的记录192.30.252.153
和192.30.252.154
-
等到你名称服务器更新:
- From your project repo, gh-pages branch. Create a CNAME file with the contents
yourdomain.com
. Commit then push. - In your DNS manager, setup two
cname
records. One for the root apex (@) and one for www. Both point toYOURusername.github.io
. If your DNS provider does NOT supportALIAS
records on the root apex (@), simply createA
records that point to192.30.252.153
and192.30.252.154
Wait til your name servers update:
dig yourdomain.com + nostats + nocomments + nocmd
这篇关于GitHub项目页面的自定义域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!