如何为 GitHub 页面设置 Google 域名
简介
Github Pages 设置起来很简单,但要使用 Google Domains 绑定自定义域名,可能会遇到一些问题。以下 4 个步骤教你如何操作。
先决条件
- 你有一个github pages仓库,例如https://github.com/Chun-Yang/Chun-Yang.github.io
- 您在google domain上购买了一个域名,例如 trentyang.com
步骤 1/4:让 gitHub 页面知道你的自定义域名
步骤 2/4:让你的自定义域名(trentyang.com)指向你的 GitHub 页面
-
转到您的 Google 域名注册页面,选择您的域名
-
添加如下截图所示的记录。注意,您需要使用“+”按钮添加更多 URL。 以下是截图中的 IP 列表:
- 185.199.111.153
- 185.199.110.153
- 185.199.109.153
- 185.199.108.153
如果这些已经过时,您也可以在github上找到最新的。
- 要确认您的 DNS 记录是否设置正确,请使用 dig 命令查找您的域名“控制台
$ dig trentyang.com +noall +answer
trentyang.com. 3600 IN A 185.199.111.153
trentyang.com. 3600 IN A 185.199.110.153
trentyang.com. 3600 IN A 185.199.109.153
trentyang.com. 3600 IN A 185.199.108.153
- Once the above is successful, your custom domain should work correctly. Go to your domain and take a look!
STEP 3/4: Let your www sub-domain (www.trentyang.com) point to your github pages
-
You can use the following dig command to confirm that your setup is correct
$ dig www.trentyang.com +nostats +nocomments +nocmd
www.trentyang.com. IN A
www.trentyang.com. 1263 IN CNAME chun-yang.github.io.
步骤 4/4:(可选但强烈推荐)为你的 GitHub 页面启用 HTTPS
- 转到您的 github 存储库设置页面,在设置> GitHub 页面> 自定义域下删除您的自定义域并保存。
- 然后将其添加回来并再次保存。
- 现在您应该能够选中“强制 HTTPS”复选框并保护您的网站!
如果您喜欢阅读,请访问我的博客https://trentyang.com/how-to-setup-google-domain-for-github-pages/
文章来源:https://dev.to/trentyang/how-to-setup-google-domain-for-github-pages-1p58