安装hexo

1
npm install -g hexo-cli

初始化

会创建devops_hexo_blog目录,并初始化项目

1
2
3
4
5
hexo init devops_hexo_blog

cd devops_hexo_blog

npm install

安装主题:

1
2
3
4
5
6
7
8
# clone主题代码,个人fork个分支方便后面变更
git submodule add -b master git@github.com:Hello-Hyman/hexo-theme-butterfly.git themes/butterfly

# 将配置文件拷贝到项目目录,方便后面更新主题文件,不会覆盖主题配置
cp themes/butterfly/_config.yml _config.butterfly.yml

# butterfly主题需要安装一些插件
npm install hexo-renderer-pug hexo-renderer-stylus --save

预览

1
2
3
4
5
6
7
8
# 清理之前的文件,更换主题需要执行一下,文件更新之类不需要
hexo clean

# 生成文件
hexo g

# 预览,启动后可访问localhost:4000
hexo s