部署hexo到github上
1. 申请github账号
- 进入
https://github.com/申请,我这里申请的用户名是lmwings - 建立个人仓库,仓库名为
lmwings.github.io,这个是规则是固定的,一个账号只有一个github page页面. 即<用户名>.github.io
2. 上传
把本地验证好的hexo个人网站,上传到lmwings.github.io仓库中
windows安装好git打开
Git Bash,输入github相关账号git config --global user.name "你的GitHub用户名" git config --global user.email "你的GitHub注册邮箱"生成
ssh密钥文件ssh-keygen -t rsa -C "你的GitHub注册邮箱"直接一直回车即可,然后找到生成的
.ssh文件夹中的id_rsa.pub文件,把内容全部复制https://github.com/settings/keys页面中新建new SSH Key,标题随便起。验证密钥是否成功
在
git bash中输入ssh git@github.comAdministrator@JIKXYRXHZ8CSKUY MINGW64 /e/work/hexo_blog $ ssh git@github.com PTY allocation request failed on channel 0 Hi lmwings! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. Administrator@JIKXYRXHZ8CSKUY MINGW64 /e/work/hexo_bloghexo一些命令# 新建文章 hexo n 新建文章1 # 新建页面 hexo page categorys # 生成 hexo g # 启动服务预览 hexo s # 部署 hexo d # 清除缓存 hexo clean修改本地
hexo代码根目录下的_config.ymal配置deploy: type: git repo: https://github.com/lmwings/lmwings.github.io.git branch: master按照部署插件
npm install hexo-deployer-git --save推送部署
hexo clean hexo g hexo d访问验证
lmwings.github.io
部署到其他平台
部署到coding
由于github是国外的,在国内访问较慢,所以我同时部署到gitee和coding上面。
步骤大部分和github上面部署是一样的,下面做简单的记录
部署到
coding首先,
https://coding.net/申请账号这里会要求先创建团体,再创建用户,可以按自己随便起,里面可以修改。
然后,创建一个和自己的用户名一样的项目仓库, 注意: 启用README.md文件初始化项目 ,最好打钩,否则可能找不到
master分支再,配置
ssh公钥,这个步骤就是github部署时候的第3步,电脑中生成的id_rsa.pub文件即为公钥,为了能在多个代码托管平台工作,需要生成一个新的。这里输入的coding就是生成是公钥文件名# Windows默认生成的路径 $ cd /c/Users/Administrator/.ssh # 生成公钥文件,后面邮箱是我注册的邮箱地址,输入文件名为 coding即会生成 coding.pud文件 $ ssh-keygen -t rsa -b 4096 -C 1321559220@qq.com Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): coding然后把
coding.pub的内容填写到https://lmwings.coding.net/user/account/setting/keys测试一下是否设置正常
ssh -T git@e.coding.net发现测试失败, 提示
git@git.coding.net: Permission denied (publickey).这个要么就是
git账号错误,要么就是ssh -T命令输入错误了.配置
hexo根目录下的_config.ymldeploy: type: git repo: github: https://github.com/lmwings/lmwings.github.io.git,master coding: https://e.coding.net/lmwings/lmwings.git,master推送部署
hexo clean hexo g hexo d需要在
condig.net上需要实名认证后才允许使用
pages功能,触发机制可以选择手动部署和自动部署构建与部署--静态网站--立即部署访问上面的地址
https://722tv0.coding-pages.com/
部署到gitee
申请
gitee账号https://gitee.com/创建项目
项目名和用户名,还有范围地址中的最好是相同的,这个可以保证可以通过
<用户名>.gitee.io进行访问,否则会多一级目录,我这里就填写lmwings,然后创建到项目中,选择
服务--Gitee Pages,部署分支选择master即可,部署目录可以不用填,启用以后会有网站地址,我的地址为https://lmwings.gitee.io/blog生成
ssh-key公钥,这个和上面方法一样# Windows默认生成的路径 $ cd /c/Users/Administrator/.ssh # 生成公钥文件,后面邮箱是我注册的邮箱地址,输入文件名为 coding即会生成 coding.pud文件 $ ssh-keygen -t rsa -b 4096 -C 1321559220@qq.com Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): rsa_gitee然后把
rsa_gitee.pub填写到https://gitee.com/profile/sshkeys(我自己使用一般直接设置账号的,不设置仓库的)测试一下是否正常
ssh -T git@gitee.com部署更新后,到
gitee Pages手动更新一下付费版本
gitee Pages Pro,可以支持自定义域名,支持推送后自动部署,普通不行访问一下
https://lmwings.gitee.io/
部署到gitlab
申请
gitlab账号https://gitlab.com/创建项目, 名称规则同
github, 即<用户名>.gitlab.io生成
ssh-key公钥,方法一样# Windows默认生成的路径 $ cd /c/Users/Administrator/.ssh $ ssh-keygen -t rsa -C 1321559220@qq.com Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): rsa_gitlab然后把
rsa_gitlab.pub填写到https://gitlab.com/profile/keys测试一下是否正常
ssh -T git@gitlab.com这个和其他的不一样,
没有显示的
gitlab pages设置界面,主要是gitlab有gitlab ci, 如果项目中存在.gitlab-ci.yml的文件,就会自动触发gitlab runner来执行这个脚本,所以和其他发布不一样,这个仓库中需要上传的是本地的hexo源码.gitlab-ci.yml脚本编写可以参考(暂时还未来得及验证。)
https://hexo.io/zh-cn/docs/gitlab-pageshttps://www.cnblogs.com/zhangnan35/p/10709252.html
一键部署
可以利用Traivs CI等持续集成平台进行部署
参考https://hexo.io/zh-cn/docs/one-command-deployment