Github Pages 自定义域名

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
去官网看了下,有文档详细描述该如何配置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.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

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
img

一个线上例子:

a CNAME file

最后,如果你的域名指向没改的。记得去DNS服务商网站去改。见页面上方我的配置。