Hexo个人免费博客(四) 部署到Coding.net

引言:

之前的博客我们已经完成了个人Hexo博客的搭建和配置,并且部署到Github上,具体过程可以参考我之前的博客《Hexo个人免费博客(一) 从零到发布Github》,但是国内访问速度有点慢,为了提高访问速度,我尝试把博客同时也部署到Coding.net上。

部署步骤

  • 注册Coding.net账号:
    打开Coding.net官网,注册一个个人账号

  • 新建项目:
    注意项目名与注册用的账户名一致,这里我用的是linshuhe1

  • 添加公钥:
    上面设置完毕之后点击创建项目,然后点击设置->部署公钥->新建部署公钥,之前部署到Github上的时候,本地目录 C\User(中文为用户)\(电脑用户名)\.ssh 目录下会有 github.rsa.pub 公钥文件,打开然后复制里面的内容,直接贴在这里的公钥框中:

    记得要勾选 授予推送权限 ,否则在后面运行hexo d时会提示错误:

    Coding.net Tips : [Deploy key is not allowed to push!]
    fatal: Could not read from remote repository.

    原因就是没有推送权限。

    打开Git命令窗口Git shell,输入一下指令:

    ssh -T git@git.coding.NET

    假如出现以下输出结果,表示公钥绑定成功:

    C:\Users\hasee-pc\Documents\GitHub> ssh -T git@git.coding.NET
    Warning: Permanently added 'git.coding.net,14.215.101.70' (RSA) to the list of known hosts.
    Coding.net Tips : [Hello! You've connected to Coding.net via SSH. This is a deploy key.]
  • 修改hexo配置:
    打开hexo本地的配置文件 _config.yml,修改 deploy 的配置内容,这里设置了运行hexo d之后部署的目的地址,原本只有Github地址,现在添加多Coding.net的地址,其中linshuhe1是注册该平台的 用户名

    
    # Deployment
    
    
    ## Docs: https://hexo.io/docs/deployment.html
    
    deploy:
      type: git
      repo:
            github: git@github.com:linshuhe1/linshuhe1.github.io.git,master
            coding: git@git.coding.net:linshuhe1/linshuhe1.git,master

    注意:github:coding:后面接地址前,必须有一个英语输出法的空格隔开,否则会报错。

    在source目录下新建一个文件,命名为Statifile,不带文件后缀。

  • 正式部署到Coding.net:
    打开命令行窗口,定位到当前hexo项目的根目录下,运行以下指令将本地博客部署到GithubCoding.net上:

    hexo g
    hexo d

    假如提交成功,在命令行会输出:

    On branch master
    nothing to commit, working directory clean
    Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
    Branch master set up to track remote branch master from git@github.com:linshuhe1/linshuhe1.github.io.git.
    Everything up-to-date
    On branch master
    nothing to commit, working directory clean
    Warning: Permanently added 'git.coding.net,180.97.181.69' (RSA) to the list of known hosts.
    Branch master set up to track remote branch master from git@git.coding.net:linshuhe1/linshuhe1.git.
    To git@git.coding.net:linshuhe1/linshuhe1.git
    * [new branch]      HEAD -> master
    INFO  Deploy done: git
  • 设置Coding Page:
    打开Coding.net的项目管理界面,打开代码->Pages服务,选择部署来源为master分支,然后保存即可:

  • 测试效果:
    打开linshuhe1.coding.me访问我们的博客,刚配置完访问的时候出现404错误很正常,需要等待10分钟左右才能生效。

参考:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值