Hexo 和 GitHub Pages 搭 Blog 记录

环境

macOs 11.12, git, Node.js

安装 Hexo

在本地创建一个文件夹 blog,进入 blog 执行如下命令安装Hexo

1
sudo npm install -g hexo

执行init命令初始化hexo,blog文件夹就是博客根目录

1
2
hexo init
subl .

生成静态页面

1
hexo g

本地启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hexo s
````

在4000端口可以看到预览

## 部署到GitHub Pages

**配置Github**

> 建立与用户名对应的仓库,仓库名必须为【your_user_name.github.io】
把本地博客部署到github上,blog文件夹中,找到_config.yml这个配置文件

```shell
deploy:
type: git
repo: https://github.com/your_user_name/your_user_name.github.io.git
branch: master

然后执行命令 npm install hexo-deployer-git –save
执行命令 hexo deploy 把博客部署到github上
your_user_name.github.io 可以看到博客部署完成了

配置和主题

_config.yml 为配置文件,根据自己需要增加修改就行
主题我用的是Next,具体设置看 http://theme-next.iissnan.com/getting-started.html