工具系列00-如何使用HEXO写博客

前置条件:

  1. 安装git
  2. 安装nodejs
  3. 安装hexo
  4. 更换hexo主题

本文将说明如何使用hexo写一篇新博客。

安装相关软件,参考下列文章:

  1. http://www.cnblogs.com/liuxianan/p/build-blog-website-by-hexo-github.html
  2. http://ruter.sundaystart.net/2015/12/13/Create-blog-with-hexo/

创建一篇新博客

在\hexo下右键,点击git bash here,执行下面这条命令来创建一篇新文章。

hexo new "如何使用HEXO写博客"

创建成功后,在\hexo\source_post下生成了 如何使用HEXO写博客.md 文件,用Sublime Text或其他Markdown编辑器打开文件。

title: 如何使用HEXO写博客
date: 2017-05-24 09:25:09
tags:

随便写点什么之后保存。

生成静态页面

hexo g

页面预览

hexo s
访问http://localhost:4000/试试吧!

上传至git

hexo d
访问 http://git用户名.github.io 看看效果吧。
上传至git时,每次都要输入git账户名和密码,很麻烦。解决办法如下,只需要两步:

  1. 输入命令:
    git config --global credential.helper store
  2. 输入 hexo d
    输入git账户名和密码

如何使用图片

我采用的方法是将图片上传至git,然后获取到图片的地址。
git的安装方法和新建目录方法在此不做赘述,感兴趣的baidu。

  1. 将图片上传到git;
    git status
    git add 文件名
    git commit -m "message"
    git push
    2.在github中查看图片,点击download,拷贝图片地址https://raw.githubusercontent.com/zhangxiaoxiaomin/img/master/45-1.png
    3.在博客中,使用markdown语法插入图片
    ![](https://raw.githubusercontent.com/zhangxiaoxiaomin/img/master/45-1.png)
    诺,就是这样