hexo 心得
花了一些時間才比較搞清楚整個 hexo 流程
教學已經很多,不再贅述
在此先附上官方教學 https://github.com/hexojs/hexo
講一個其他教學沒提到,但我花比較多時間的地方
遇到的問題是只要更換預設的 theme 就會出錯
不是整個 index 是空的,就是只有純文字但沒有我看到的樣式
我以為是設定出錯,但我又是照著每篇都講得差不多的步驟弄過來的
花了不少時間釐清問題
後來發現主要原因是因為 theme 年久失修,導致靜態檔案的過程有錯誤
所以無法順利產生正確的檔案出來
所以建議各位新朋友,可以找找近期還有在維護的 theme
例如在 Gihub 搜尋 hexo theme
然後 Sort 選 Most starts
或者 Recently updated
最後也要提醒一下,如果設定都使用預設
workflow 裡面,submodules
記得給定 true
把 theme 當作 submodule 上傳即可1
2
3
4- name: Checkout
uses: actions/checkout@v1
with:
submodules: true # Checkout private submodules(themes or something else).
我的完整 CI 設定在這1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44name: Hexo Deploy
on:
push:
branches:
- publish
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Deploy blog.
steps:
- name: Checkout
uses: actions/checkout@v1
with:
submodules: true # Checkout private submodules(themes or something else).
# Caching dependencies to speed up workflows. (GitHub will remove any cache entries that have not been accessed in over 7 days.)
- name: Cache node modules
uses: actions/cache@v1
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
# Deploy hexo blog website.
- name: Deploy
id: deploy
uses: sma11black/[email protected]
with:
deploy_key: ${{ secrets.DEPLOY_KEY }}
#user_name: your github username # (or delete this input setting to use bot account)
#user_email: your github useremail # (or delete this input setting to use bot account)
#commit_msg: ${{ github.event.head_commit.message }} # (or delete this input setting to use hexo default settings)
# Use the output from the `deploy` step(use for test action)
- name: Get the output
run: |
echo "${{ steps.deploy.outputs.notify }}"
如果你想改動一些設定細節,那請記得把 themes/your_theme/.git
資料夾砍掉
把整個 themes
資料夾都上傳