在coding上搭建Hexo博客

作者: 秒单 | 来源:发表于2016-07-02 07:43 被阅读2786次

Coding有一个Pages的服务,可以用来托管静态网页.国内访问速度比github快得多, 也可以绑定域名.

Hexo的安装和使用

环境安装

需要预先好git和node.js

全局安装hexo和hexo的运行工具

  npm install hexo
  npm install hexo-cli

初始化项目

这里使用blog作为项目名

  hexo init blog

运行hexo

  cd blog
  hexo server

查看 http://localhost:4000/ 可以浏览到hexo初始化的默认主体博客

coding上创建项目

在coding的上面创建一个新项目.

Pages服务有个特点, 如果项目名和用户名一样. 就可以使用 username.coding.me访问发布的网站, 否则则是 username.coding.me/projectname

开启Pages服务

进入项目页面的'Pages服务'那一栏,立即开启. 默认使用了coding-pages的branch

绑定ssh证书

本地生成ssh证书
把证书的公钥(~/.ssh/id_rsa.pub)的内容拷贝到coding个人账户下的SSH公钥里面

配置hexo的deploy方式

在一开始hexo生成的blog目录下面找到_config.yml
在文件最低端加上deploy到coding的配置

deploy:
  type: git
  repo:
    coding: git@git.coding.net:username/projectname.git,coding-pages

注意coding的配置是 coding:{项目git地址},{branch}

最后执行生成静态文件

hexo g

由于coding的Pages服务是默认执行jekyll项目, 静态项目需要一个.nojekyll文件标识.
所以第一次执行, 需要在生成的public文件夹中加入一个 .nojekyll 空白文件

还有部署命令

hexo d

就可以发布成功了

访问username.coding.me或者username.coding.me/projectname试试吧

后面每次更新博客的时候, 就只需要重复上面的命令hexo g && hexo d就可以立刻发布

查看实例 http://ipro.xin

相关文章

网友评论

  • 9f8b59a1f1d7:其实我想问 coding pages如何开启https的 :yum:
  • franklight:请问绑定自己的域名收费吗
  • 0fe9a54ea801:按照你写的成功了,我好奇你是买域名了吗?后面没有coding.me
    0fe9a54ea801:@养草的程序员 好的~
    秒单:@_helio_27249 是买了 用cname指过去 coding
  • syncwt:coding 的演示收费。。我搭了一下没成功。。
    ```
    $ hexo d
    INFO Deploying: git
    INFO Clearing .deploy_git folder...
    INFO Copying files from public folder...
    warning: LF will be replaced by CRLF in 2016/07/02/hello-world/index.html.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in archives/2016/07/index.html.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in archives/2016/index.html.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in archives/index.html.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in css/style.css.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.css.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons.js.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-media.js.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.css.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs.js.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.css.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.js.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.pack.js.
    ```
    秒单:@WENTAO_Wanna 发个coding的地址我看看 :sweat_smile:
    syncwt:@种种花养养草 没有error...就是出不来页面,报404
    秒单:@WENTAO_Wanna Coding Pages服务是免费的, 你贴的那一段都只是warning. 最后有错误吗?

本文标题:在coding上搭建Hexo博客

本文链接:https://www.haomeiwen.com/subject/jsrqjttx.html