数据分析师Hexo

Hexo部署和使用指北

2014-12-20  本文已影响1497人  黑夜之旅

首先要有Git和npm环境.

  1. 安装hexo: npm install hexo -g.

  2. 初始化hexo: hexo init blog, 将建立"blog"为名的目录并在此初始化, Hexo 即会自动在目标文件夹建立网站所需要的所有文件.

  3. 安装依赖包: cd dir && npm install.

  4. 本地启动测试: hexo server, 可以访问127.0.0.1:4000查看.
    以上参考HEXO.

  5. Github上新建一个repository, 名字为yoursite.github.io.

  6. 修改本地的_config.yml文件, 找到#site一栏, 修改博客的title, 然后在最后的deploy:处增加:

  type: github
  repository: https://github.com/Your_Github_Account/yoursite.github.io.git
  branch: master
  1. 修改完后, 把本地博客文件部署到github上去:
hexo generate # 生成静态页面至public目录
hexo deploy # 将.deploy目录部署到GitHub
  1. 在github部署完成后, 访问yoursite.github.io就能看到自己搭建的博客了.

  2. 添加/修改文章

hexo n 文章名 #在source\_posts\目录下新建文章 
hexo g # 生成静态文件, 每新建文章都需要执行
hexo d # 部署到git
  1. 添加评论系统:
    国外比较常用的评论系统有disqus等, 这个在hexo中也是默认开启的, 如果我们要添加其他的评论系统, 在国内推荐使用:搜狐畅言-专业的社会化评论系统.
    首先需要在配置文件中禁用disqus, 编辑根目录的_config.yml文件:
    查找并注释掉disqus_shortname一行.
    然后, 编辑themes\landscape\layout_partial\comment.ejs并添加:
<% if ( page.comments){ %>
<section id="comment">
畅言js代码
</section>
<% } %>

参考:
http://www.jianshu.com/p/05289a4bc8b2
http://segmentfault.com/blog/zhongbaitu/1190000000458953

上一篇下一篇

猜你喜欢

热点阅读