新建 Github Page 仓库并配置 git
git 我早就配置过,新建仓库也很简单,详见参考教程
安装 Hexo
建立 Hexo 的根文件夹(我是 GithubBlog),进到里面执行下面步骤
安装 Hexo 并初始化
我是 Windows 系统,已安装过 npm,执行:
1
2
3npm install -g hexo-cli
hexo init
npm install本地预览
1
2hexo g # 生成页面
hexo s # 本地预览此时访问 http://localhost:4000 应该能看到 Hexo 的默认欢迎页面
部署到 Github Pages
安装 hexo-deployer-git
1
npm install hexo-deployer-git --save
修改 _config.yml 文件末尾的 Deployment 部分
1
2
3
4deploy:
type: git
repository: git@github.com:用户名/用户名.github.io.git
branch: main部署
1
hexo d
使用 cactus 主题
安装 cactus
在 Hexo 根目录下执行
1
git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus
修改 Hexo 配置文件
找到 Hexo 根目录下的 _config.yml,修改 theme 配置
1
2# theme: landscape
theme: cactus修改 cactus 配置文件
cactus 配置文件为 themes\cactus\_config.yml, 可以按需配置
cactus 设置字体大小
cactus 的配置文件里没有提供对字体大小的配置选项,要修改的话需要找到 themes\cactus\source\css\_variables.styl,修改 $font-size 数值。
发布文章
每次更新完都执行
1 | hexo g |