一、 安装node.js
Node官网:http://nodejs.cn/download/
如果你的电脑原先没有安装git,需要下载安装:https://git-scm.com/downloads
Git配置:
git config --global user.name "your name"
git config --global user.email "your email"
二、安装cnpm
安装node是因为node自带了npm包管理工具,但是这个工具软件源在国外,访问速度较慢
国内常用的有cnpm,淘宝的一个工具
安装:
npm install -g cnpm --registry=https://registry.npm.taobao.org
三、安装hexo
以上软件安装完成之后,就可以安装hexo了
安装hexo:
cnpm install -g hexo-cli
四、生成博客
在磁盘本地新建一个工作目录,然后在终端打开该目录,输入该命令进行初始化
hexo init
在./source/_posts/目录下,以md的格式的文件进行博客编写
常用命令:
生成html文件:
hexo g
清除缓存:
hexo cl
本机预览:
hexo g
远程推送:
hexo d
五、远程推送
修改工作空间根目录下的配置文件,_config.yml
添加或修改为:
deploy:
type: git
repo: https://github.com/itweixiang/itweixiang.github.io.git
branch: master
修改完成后,使用hexo d命令推送到代码仓库
代码仓库规范名称严格:自己的名称空间.github.io,如itweixiang.github.io
六、更换主题
Hexo的主题比较多,这里只演示更换技术点
在工作目录下输入 如下命令:
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
然后修改_config.yml文件
theme: yilia
推送到代码仓库进行查看,
hexo d
这时在浏览器地址栏中,输入自己的名称空间.github.io
就可以进行查看