使用 Hexo + GitHub

什麼是 Hexo

Hexo 是一套用 NodeJS 寫的 blog framework ,可以透過 hexo 的指令非常快速的建立文章,以下會有簡易指令教學

另外這有記錄我在使用 Hexo 時的採雷狀況與解決方法 - Hexo 採雷大小事

什麼是 GitHub Page

GitHub Page 提供所有 GitHub 的用戶可以直接將靜態網頁直接放上 GitHub 中,即可直接於 https://[account].github.io 查看網頁內容的服務。

如何使用 GitHub Page

直接於自己的 GitHub 帳號直接建立一個 [account].github.io 的 Public Repo ,於 Repo 中上傳靜態網頁即可在 https://[account].github.io 上查看網頁。

為什麼想要使用 Hexo + GitHub

  1. Hexo 為 Open Source 軟體可以非常自由的依照自己的需求去調整 Source Code 。
  2. 客製化的網址需求,雖說 LogDown 也可以,但… 需要付費才可以使用,其實還蠻貴的。
  3. GitHub Public Repository 無空間上限(嚴格來說不是無上限,請參考: GitHub - What is my disk quota?)。
  4. 主機交給 GitHub 管,只需要單純的上 Code 就好不需要去架設與管理主機,相對穩定。
  5. 多了個機會可以了解 GitHub Page 這個服務,詳細參考這裡
  6. 幫自己的 GitHub Contributions 多一點色彩,每更新一次 Blog 都會 deploy 到 GitHub 上,也就會增加自己的 Contributions 。

Hexo Command

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 第一次使用需要先 init hexo folder 與安裝套件
$ hexo init <folder> // init hexo folder
$ cd <folder>
$ npm install
// 新增文章
$ hexo new [layout] <title> // or hexo n [layout] <title>
// layout 可以不要填寫
// title 建議使用雙引號刮起來
// 產生靜態檔
$ hexo generate // or hexo g
// 發表草稿,這個功能我蠻少用的
$ hexo publish [layout] <filename>
// 啟用 hexo 伺服器
$ hexo server // or hexo s
// Deploy 至 remote
$ hexo deploy // or hexo d
// 清除快取檔案
$ hexo clean

Hash 使用 Blog 的歷史

參考資料