默认已经安装git for windows,由此可以使用git bash。所有操作均在git bash中进行。
安装node.js
安装后如果npm在git bash中无效则需要将npm添加到系统环境变量中。
安装hexo
在git bash中输入
1 2
| $ npm install -g hexo-cli $ npm install hexo --save
|
搭建博客
创建博客目录
1 2 3
| $ cd where/you/like $ mkdir my_local_blog $ cd my_local_blog
|
创建hexo目录
安装hexo插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| npm install hexo-generator-index --save npm install hexo-generator-archive --save npm install hexo-generator-category --save npm install hexo-generator-tag --save npm install hexo-server --save npm install hexo-deployer-git --save npm install hexo-deployer-heroku --save npm install hexo-deployer-rsync --save npm install hexo-deployer-openshift --save npm install hexo-renderer-marked@0.2 --save npm install hexo-renderer-stylus@0.2 --save npm install hexo-generator-feed@1 --save npm install hexo-generator-sitemap@1 --save npm install hexo-renderer-ejs --save
|
生成博客
或者
查看本地博客效果
通过
或者
启动本地服务器,然后在浏览器的地址栏输入http://localhost:4000/,就可以测试博客了。
发布博客
首先配置_config.yml文件(此文件在hexo init之后会被覆盖掉,建议备份)。在此文件中加入
需要通过输入
来配置ssh
1 2 3 4 5 6
| # Deployment ## Docs: http: deploy: type: git repository: git@github.com:username/username.github.com.git #<--这里使用ssh branch: master
|
这样之后就可以通过
或者
将你的博客发布到github上了。此时你可以发现你的’my_local_blog’目录下的’.deploy_git’已经被push到github上了。以后每次执行’hexo deploy’都会将更新的博客push到github上。