github注册及建立仓储
- 在github主页完成注册;
- 验证邮箱;
- 创建仓储,其中repository name必须为username.github.io;
git的安装及添加ssh-key
在ubuntu下,使用以下命令安装git:1
2
3$ sudo apt-get install git
$ git config --global user.email "Your emaill address"
$ git config --global user.name "Your username on github.com"
使用以下命令生产ssh-key1
$ ssh-keygen -t rsa -C "Your email address" #需要指定key文件名,使用默认即可
默认生成的ssh-key文件位于~/.ssh/
目录下,其中的id_rsa
和id_rsa.pub
为我们需要的文件。将id_rsa.pub
文件的文本内容添加到github的ssh-key中。使用以下命令测试是否成功:1
$ ssh -T git@github.com
hexo的安装
1.安装nvm1
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
2.安装node.js1
2
3
4$ nvm install v3.3
$ nvm ls #List installed versions
$ nvm use 3.3
$ nvm current #Display currently activated version
3.安装hexo1
$ npm install -g hexo
本地hexo初始化
1.初始化hexo目录1
2$ hexo init ~/myblog
$ npm install
2.生成静态文件1
$ hexo g
3.本地服务器预览1
$ hexo s #打开浏览器通过http://0.0.0.0:4000/访问查看
发布
1.安装hexo-deployer-git1
$ npm install hexo-cli -g
2.在博客目录下找到_config.yml
文件,添加或修改:1
2
3
4
5deploy:
type: git
repo: git@github.com:USERNAME/USERNAME.github.io.git
branch: master
message: "g"
注意,所有的冒号后面必须有空格!!!
3.发布1
2$ hexo g
$ hexo d
预览
在浏览器中打开http://USERNAME.github.io.git
页面访问静态博客。
添加博客文章并发布
使用以下命令添加新的文章至目录\source\_posts\
:1
$ hexo new "article1"
随后可以在目录\source\_posts\
中找到markdown格式文件article1.md
。可以书写并修改其内容,然后使用以下命令发布:1
2
3$ hexo clean
$ hexo g
$ hexo d
使用数学公式
安装hexo-math,随后即可在文章中插入公式。1
npm install hexo-math --save
可以在hexo-math项目主页找到如何插入公式。
配置过程中遇到的问题:How to config it to make it work? #26
注意,hexo-math保持更新,且不同版本的安装与配置存在区别,在Google上搜索到的结果可能已经弃用了,所以以项目主页说明为准。
参考
github注册与入门http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
搭建静态博客http://blog.wpeace.cn/2015/07/22/%E4%BD%BF%E7%94%A8github%E5%92%8Chexo%E6%90%AD%E5%BB%BA%E9%9D%99%E6%80%81%E5%8D%9A%E5%AE%A2/
ERROR Deployer not found: githttp://github.com/hexojs/hexo/issues/1154