Windows + Hexo + Github Pages 搭建流程(简)及注意事项

安装Git并与个人Github绑定

安装Node.js

  • 建议选择稳定版本
  • 可自行配置 node_global(全局包存放目录)和 node_cache(缓存目录)地址
1
2
npm config set prefix "path\to\node_global"
npm config set cache "path\to\node_cache"
  • 注意添加 node_modules 到环境变量

安装Hexo及使用

  • (可选)换源
1
npm config set registry https://registry.npm.taobao.org
  • 安装
1
npm i hexo-cli -g
  • 使用
1
2
3
4
5
6
cd path\to\your_blog
hexo init .
npm install

hexo g # 生成静态网页
hexo s # 此时浏览器打开 http://localhost:4000 可以访问
  • 安装主题,以Butterfly为例
1
2
cd path\to\your_blog\theme
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

推送到Github Pages

  • 新建仓库,注意命名 username/username.github.io
  • (可选)绑定个人域名
1
2
cd path\to\your_blog\source
add CNAME # 文件没有后缀名,里面填入已经解析完成的个人域名
  • 推送
1
2
3
hexo clean
hexo g
hexo d # 推送到个人仓库,第一次推送会弹登录框,可用于验证是否配置成功

参考链接

Butterfly Github仓库
Butterfly 演示站及配置教程