Github Pages 自定义域名
2017-09-05 20:27
253 查看
Github Pages 自定义域名
12年买域名的时候8块钱。买了5年。现在域名到期变贵了。。要35元/年, /(ㄒoㄒ)/~~观众:35块都嫌贵,你这个臭屌丝。。。
O(∩_∩)O 好吧,不贵不贵。
现在有个github pages. 官网可以支持 hexo 和 jeckly(不会拼).我写了自己的build.js。没用它们。
今天在万网把域名
blog.yanggaofei.cn指向了
bryanyang.github.io,配置如下:
记录类型 | 主机记录 | 解析线路 | 记录值 | MX优先级 | TTL |
CNAME | blog | 默认 | bryanyang.github.io | -- | 10分钟 |
http://blog.yanggaofei.cn出现大大的404:
去官网看了下,有文档详细描述该如何配置custom domain
Setting up a custom domain
1.Pick your custom domain and register it with a DNS provider. A DNS provider is a company that allows users to buy and register a unique domain name and connect that name to an IP (Internet Protocol) address by pointing your domain name to an IP address
or a different domain name. A DNS provider is also called a domain registrar or DNS host.
2.Set up your pages site repository by creating and committing a CNAME file that contains your custom domain.
3.Set up your custom domain with your DNS provider. Our guides outline how to set up your pages custom domain with your DNS provider depending on the type of custom domain you have:
Setting up an apex domain such as example.comSetting up a www subdomain such as www.example.comSetting up an apex domain and www subdomain such as example.com and www.example.comSetting up a custom subdomain such as blog.example.com
第2步,需要在repository下面增加
CNAME文件:Adding your custom domain to a CNAME file
1.去到自己的 Pages site repository.
2.在"Branches" 菜单, 切换到你的 repository's Pages 分支:
For User and Organization Pages sites, the Pages branch is master.For Project Pages sites, the Pages branch is gh-pages.
3.在文件列表中, 点击 New file.
4.文件名, 填写 CNAME (全部大写!).
5.在文件内容中, 添加一行来指定你的域名,不要填写
https://或
http://. 例如, 用
www.example.com, 而不是
https://www.example.com. 注意只能添加一行纪录。
6.在页面底部,填入commit message上传。
7.(直接传到master就行,该条可略过)Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is master, you should choose to create a new branch for your commit and then create a pull request.
8.(略)Click Propose new file.
OK。如果操作正确的话,就可以在Setting里看到新的domain了。
一个线上例子:
a CNAME file
最后,如果你的域名指向没改的。记得去DNS服务商网站去改。见页面上方我的配置。
附录,本文md文件:
## Github Pages 自定义域名
------
12年买域名的时候8块钱。买了5年。现在域名到期变贵了。。要35元/年, /(ㄒoㄒ)/~~
观众:35块都嫌贵,你这个臭屌丝。。。
O(∩_∩)O 好吧,不贵不贵。
现在有个github pages. 官网可以支持 hexo 和 jeckly(不会拼).我写了自己的build.js。没用它们。
今天在万网把域名`blog.yanggaofei.cn`指向了`bryanyang.github.io`,配置如下:
|------------------------------------
记录类型|主机记录|解析线路|记录值|MX优先级| TTL
CNAME|blog|默认|bryanyang.github.io|--|10分钟
------------------------------------|
结果访问`http://blog.yanggaofei.cn`出现大大的404:
![404](https://segmentfault.com/img/bVq6HR)
去官网看了下,有文档详细描述该如何配置**custom domain**
[Setting up a custom domain](https://help.github.com/articles/quick-start-setting-up-a-custom-domain/)
>
1.Pick your custom domain and register it with a DNS provider. A DNS provider is a company that allows users to buy and register a unique domain name and connect that name to an IP (Internet Protocol) address by pointing your domain name to an IP address or a different domain name. A DNS provider is also called a domain registrar or DNS host.
2.Set up your pages site repository by creating and committing a CNAME file that contains your custom domain.
3.Set up your custom domain with your DNS provider. Our guides outline how to set up your pages custom domain with your DNS provider depending on the type of custom domain you have:
* Setting up an apex domain such as example.com
* Setting up a www subdomain such as www.example.com
* Setting up an apex domain and www subdomain such as example.com and www.example.com
* Setting up a custom subdomain such as blog.example.com
### 第二步,需要在repository下面增加`CNAME`文件:[Adding your custom domain to a CNAME file](https://help.github.com/articles/setting-up-your-pages-site-repository/)
>
1.去到自己的 Pages site repository.
2.在"Branches" 菜单, 切换到你的 repository's Pages 分支:
* For User and Organization Pages sites, the Pages branch is master.
* For Project Pages sites, the Pages branch is gh-pages.
3.在文件列表中, 点击 **New file**.
![The New file buttonAbove the file list, click New file](https://help.github.com/assets/images/help/repository/create_new_file.png)
4.文件名, 填写 *CNAME* (全部大写!).
5.在文件内容中, 添加一行来指定你的域名,不要填写 `https://` 或 `http://`. 例如, 用 `www.example.com`, 而不是 `https://www.example.com`. 注意只能添加一行纪录。
6.在页面底部,填入commit message上传。
![img](https://help.github.com/assets/images/help/repository/write-commit-message-quick-pull.png)
7.(直接传到master就行,该条可略过)Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is master, you should choose to create a new branch for your commit and then create a pull request.
![img](https://help.github.com/assets/images/help/repository/choose-commit-branch.png)
8.(略)Click Propose new file.
![img](https://help.github.com/assets/images/help/repository/new-file-commit-button.png)
OK。如果操作正确的话,就可以在**Setting**里看到新的domain了。
![img](https://help.github.com/assets/images/help/repository/repo-actions-settings.png)
![img](https://help.github.com/assets/images/help/settings/pages-section.png)
一个线上例子:
[a CNAME file](https://github.com/muan/muan.github.com/blob/master/CNAME)
-------
最后,如果你的域名指向没改的。记得去DNS服务商网站去改。见页面上方我的配置。
通过
build.js之后,生成了 json 数据文件,F12见控制台网络请求。
相关文章推荐
- GitHub Pages和每个项目绑定自定义域名(支持多个和顶级域名)
- 解除hexo在github pages自定义域名绑定的方法
- 使用自定义域名访问github上的pages
- 【前端】Github Pages 与域名关联简明教程
- github pages + Hexo + 域名绑定搭建个人博客
- 免费开源Github Pages空间可绑域名搭建个人博客存放图片文件
- github pages + Hexo + 域名绑定搭建个人博客
- Github Pages 与域名关联简明教程
- github pages + Hexo + 域名绑定搭建个人博客
- 为 Github Pages 绑定域名
- 解决GitHub Pages自有域名二级目录无法访问问题
- GitHub 博客自定义域名配置(阿里)
- 利用github pages打造专属域名
- 为Github pages更换域名
- github pages绑定域名
- 第39篇 免费博客github Pages绑定域名
- 基于Hexo+GitHub Pages+独立域名 搭建博客详细教程
- github 建设网站 自定义绑定域名
- github pages + 域名和外网ip访问本地服务器
- github pages + Hexo + 域名绑定搭建个人博客增强版