變更Hexo的主題

繼上一篇說明如何在Github上用hexo建立blog,這次要介紹怎麼樣變更blog的主題(theme)。

找到你喜歡的主題(Theme)

Hexo官方網站有提供一些主題可以給你使用,這邊用到的主題也是官方提供的喔!

Offical themes

把原始碼完整的抓下來

在選擇主題後,試著找到他們的Github repository連結。

Find out theme's repository url

接著把HTTPS的git連結複製下來。

Copy git repository url

git clone指令把它抓下來,並放在themes/cactus-dark資料夾下。

1
2
3
4
5
6
7
8
9
C:\Users\anson\blog\jsgao0> git clone https://github.com/probberechts/cactus-dark.git themes/cactus-dark
Cloning into 'themes/cactus-dark'...
remote: Counting objects: 1571, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 1571 (delta 10), reused 0 (delta 0), pack-reused 1526Receiving objects: 99% (1556/1571), 5.29 MiB | 542.00 KiB/s
Receiving objects: 100% (1571/1571), 5.41 MiB | 539.00 KiB/s, done.
Resolving deltas: 100% (671/671), done.
Checking connectivity... done.

在Hexo設定檔切換主題名稱

Hexo的設定檔就是_config.yml這個檔案。 裡頭的theme值預設為landscape,我們要將其修改成cactus-dark

Change theme name to cactus-dark in _config.yml

結論與心得

單純地替換主題並不難,如果要做些客製化或是增加一些插件,就需要花更多時間了。