Hexo部署

准备

本地环境

Hexo

1
npm install -g hexo-cli

Github

新建一个Repository,命名为用户名.github.io

本地配置

初始化Hexo

1
2
hexo init
npm install

部署本地看一下

1
hexo clean && hexo g && hexo s

远程Github推送

安装deployer

1
npm install hexo-deployer-git --save

打开F:\blog\_config.yml,找到 deploy。修改如下,其中repo填写你自己的仓库名字

Image

生成公私钥

1
ssh-keygen -t rsa -C "注册git使用的邮箱"

找到生成的 id_rsa.pub 公钥文件(在C:\Users\pc.ssh下),复制公钥内容。

在 GitHub 头像下的 Settings 里找到添加 SSH key,点击New SSH key,将刚刚生成的公钥 id_rsa.pub 文件里的内容复制到 Key 里面

1
ssh -T [email protected]

此时会显示以下内容,说明成功了

Image

部署到Github Pages

1
hexo clean && hexo g && hexo d

安装Butterfly主题

1
npm install hexo-theme-butterfly

应用主题

修改 Hexo 根目錄下的_config.yml,把主題改為butterfly

1
theme: butterfly

在 hexo 的根目錄創建一個文件_config.butterfly.yml,並把主題目錄的_config.yml內容複製到_config.butterfly.yml去。( 注意: 複製的是主題的_config.yml,而不是 hexo 的_config.yml)