多平臺發(fā)布
在 GitHub 和 Coding 上都有博客虏杰,分開一一發(fā)布比較麻煩,其實 Hexo 是支持在多個平臺發(fā)布的瘸彤。
修改 Hexo 主目錄下的 _config.yml 配置文件即可
deploy:
- type: git
repository: https://github.com/Hongye567/Hongye567.github.io.git
branch: master
- type: git
repository: https://git.coding.net/Honye/Honye.git
branch: master
免輸入密碼
Hexo 每次提交時都要求輸入用戶名和密碼笛钝,尤其在多平臺發(fā)布時需要多次輸入用戶名和密碼很是麻煩玻靡。
要求輸入密碼的原因是我們的倉庫地址用的是 HTTPS 不是 SSH。
1. 首先生成 SSH 密鑰
$ git config --global user.name "yourname" // 配置 git 用戶名
$ git config --global user.email "youremail@email.com" // 配置 git 郵箱
$ cd ~/.ssh // 查看是否已有.ssh文件夾臼朗,若有可備份刪除
$ ssh-keygen -t rsa -C "youremail@email.com" // 生成 SSH 密鑰
生成密鑰時會提示選擇密鑰保存路徑蝎土,直接回車默認(rèn)路徑即可。
會提示輸入密碼和確認(rèn)密碼黎炉,直接回車代表不設(shè)置密碼醋拧。
2. 部署公鑰
在 GitHub 和 Coding 在部署公鑰操作基本一樣,我不一一贅述庆械,僅以 GitHub 為例菌赖。
打開 GitHub 項目,選擇上方菜單 Settings堕绩,接著選擇左側(cè)菜單 Deploy keys邑时,接著 Add deploy key晶丘,打開前面密鑰所在文件夾,將 id_rsa.pub 文件中的內(nèi)容粘貼在 GitHub 即可浅浮。
3. Hexo 提交
修改 Hexo 主目錄下 _config.yml 配置文件中的參數(shù)
deploy:
- type: git
repository: git@github.com:Hongye567/Hongye567.github.io.git
branch: master
- type: git
repository: git@git.coding.net:Honye/Honye.git
branch: master
現(xiàn)在提交就可以不用輸入密碼了滚秩。提交的時候可能會報 authenticity 可靠性問題,直接輸入 yes 忽略即可郁油。