一、使用hexo deploy部署部落格到Github
使用參考
** 先安裝個擴充
$ npm install hexo-deployer-git --save
**
1.修改部落格根目錄下的 _config_yml
檔案
_config_yml
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsICMyYTMvw1dvwlMvwlM3VWaWV2Zh1Wa-cmbw5iavF3cxYDOvZDOvwlM5kzNzIDNtUGall3LcVmdhNXLwRHdo9CXt92YucWbpRWdvx2Yx5yazF2Lc9CX6MHc0RHaiojIsJye.png)
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: [email protected]:yeshan333/yeshan333.github.io.git # 這個可到Github倉庫拿
branch: master
複制
2.部署到GitHub repo
生成ssh keys
ssh-keygen -t rsa -C "郵件位址@youremail.com" #生成新的key檔案,郵箱位址填注冊Github時用的
複制
将生成的ssh keys添加到Github的deploy keys中
-
- 複制key
** 這裡用到.ssh目錄下,id_rsa.pub檔案中的那串key**
-
- 到GitHub的yourname.hithub.io倉庫添加那串key到deploy keys中
-
- 測試一下是否添加成功了:
ssh -T [email protected]
複制
部署部落格
- 先配好git使用者資訊
git config --global user.name "你的名字" # github使用者名
git config --global user.email "郵箱@郵箱.com" # github郵箱
複制
- 部署部落格到倉庫
hexo g # 生成靜态檔案
hexo d # 部署到遠端倉庫
複制
通路https://yourname.github.io檢視結果
** 到此,整個部落格搭建完成了 **
以下是寫的是部落客題的更換,主題可以自己寫,也可以使用别人寫的,可去這裡https://hexo.io/themes/找喜歡的主題,如果使用的是别人的主題,需要閱讀主題使用文檔進行相關配置。
二、Hexo主題設定
-
- 更換主題
cd進themes目錄
cd themes
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
複制
-
- 對根目錄下的
檔案進行修改config_yml
- 對根目錄下的
cd themes/yilia
git pull #更新主題
複制
-
- 預覽新主題
hexo clean # 清楚緩存,删除public目錄
hexo g # 生成新的部落格靜态檔案
hexo s
複制
去http://localhost:4000預覽,沒毛病就
hexo d
部署到遠端倉庫。