hexo push后自动部署github pages
hexo有几种部署方式,一种是本地编译后,直接push public路径下的静态文件,一种是通过cli方式,向仓库提交source下的的markdown文件,触发action.实现自动部署
本文主要说明后一种方式.
创建github workflow
在hexo的根目录的.github/workflows/pages.yml路径下创建文件,文件内容:
1 | name: Pages |
创建github pages
参考 https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site
创建完成后,微调一下:
在settings->Pages->Build and deployment->Branch选项中,把branch改成gh-pages
初始化本地仓库
1 | git init . |
gitgnore
由于使用了github的自动部署功能,所以无需上传静态文件,在hexo根目录添加.gitignore文件
1 | public/ |
提交
最后提交到main分支
1 | git push -u origin main |
提交完成后,在github的action选项中可以看到正在构建,构建完成,就可以在https://${your-username}.github.io路径访问你的在线博客了
参考
hexo push后自动部署github pages
https://fingergohappy.github.io/2023/09/20/hexo-auto-deploy/

