将静态站点部署到Coding.net

本站是基于https://github.com/wendal/gor生成的静态站点。

下面介绍如何将静态站点部署到coding.net上。

注册coding并新建项目

首先注册coding.net,注册完后新建项目。

项目名称为*.coding.me,以此格式新建的项目可以使用Coding Pages服务。

Pages服务设置

建立完成后,在项目设置中找到Pages服务服务进行设置。

  • 部署来源

选择master分支

  • 自定义域名

添加自定义域名,建议同时添加domain.com和www.domain.com,并且设置一个为首选项,另一个跳转到首选项。然后将自己的域名CNAME指向pages.coding.me

  • 强制HTTPS访问

打开该选项,则为你的域名自动申请设置** Let’s Encrypt证书,并开启https**访问。

  • Hosted by Coding Pages

新站点都会有coding pages跳转页,按照Hosted by Coding Pages说明,在首页添加规定连接后,可以提交申请不显示跳转页。

使用Git部署站点

首先推荐配置SSH公钥以便于操作。

$ ssh-keygen -t rsa -C "name@domain.com"  //在此设置为coding.net帐号邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dotbbq/.ssh/id_rsa):
Created directory '/c/Users/dotbbq/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/dotbbq/.ssh/id_rsa.
Your public key has been saved in /c/Users/dotbbq/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Tt/3424234sdfasdfadfs1234234sdfafdsi0 name@domain.com
The key's randomart image is:
+---[RSA 2048]----+
|     ... ...o  . |
|      + o o   +..|
|*... + * . o . o+|
|    o = + o . ..o|
| . . o =S+ o .. .|
|. o   Bo+. .o.   |
| +.+   ......    |
|o.=.o o  .+ .    |
|.. ..+ .oo.o     |
+----[SHA256]-----+

生成完后,将/c/Users/dotbbq/.ssh/id_rsa.pub的内容粘贴到coding.net的个人设置->SSH公钥中进行添加。

下来进行验证

$ ssh -T git@git.coding.net
The authenticity of host 'git.coding.net (123.59.85.184)' can't be established.
RSA key fingerprint is SHA256:3424234sdfasdfadfs1234234sdfafdsi0+Vg/Ik.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.coding.net,123.59.85.184' (RSA) to the list of known hosts.
Coding 提示: Hello alairs, You've connected to Coding.net via SSH. This is a personal key.
alairs,你好,你已经通过 SSH 协议认证 Coding.net 服务,这是一个个人公钥

设置git用户名和email

$ git config --global user.name "name"                //coding.net用户名
$ git config --global user.email "name@domain"        //coding.net邮箱

将远程的项目clone下来

$ git clone git@git.coding.net:name/name.coding.me.git

将静态站点文件拷贝至name.coding.me目录

部署文件到coding.net

$ git add .
$ git commit -m "update"
$ git push