學習關於 Hexo 的基本指令,包括建立專案、新文章、新增 menu、跑 server 和 deploy 等等
建立一個Hexo專案
1 2
| $ hexo init 專案名稱 $ hexo init blog
|
(about/tags/categories…)
1 2 3
| $ hexo new page about $ hexo new page tags $ hexo new page categories
|
執行完成後source資料夾底下會出現對應資料夾和其底下的index.md
建立新文章
執行完成後source/_posts資料夾底下會出現我的第一篇文章.md
跑server
修改_config.yml的deploy設定
1 2 3 4
| deploy type: git repository: git@github.com:你的帳號/你的帳號.github.io.git branch: main
|
repository: 到你的github倉庫點選Code -> copy按鈕,即可複製完成

產生靜態檔案
安裝hexo-deployer-git
(第一次deploy前執行即可)
1
| $ npm install --save hexo-deployer-git
|
部署到遠端
一鍵部屬
- 安裝 hexo-deployer-git
- 清空
_config.yml
的現有資料,並新增以下組態:
1 2 3 4 5
| deploy: type: git repo: https://github.com/<username>/<project> branch: gh-pages
|
- 執行
hexo clean && hexo deploy
。
- 瀏覽
<GitHub 用戶名>.github.io
檢查你的網站能否運作。