Hexo博客框架安裝教程
安裝流程
-
安裝nodejs
-
安裝cnpm(可選)
npm install cnpm -g --registry=https://registry.npm.taobao.org
- 安裝hexo-cli
cnpm install -g hexo-cli
- 驗證安裝
hexo -v
- 初始化並啓動
hexo init blog
cd blog
npm intall
hexo server(或者s)
- 寫文章
hexo n “標題”
- 生成並預覽
hexo clean
hexo g
hexo s
發佈到github
- 安裝hexo-deployer-git
cnpm install --save hexo-deployer-git
- 配置_config.yml
此處主要是與github做綁定,將本地修改的直接推送到github上。
注意:需要先在github上創建項目名爲:用戶名.github.io
deploy:
type: git
repo: https://github.com/用戶名/項目名
branch: master
- 部署到github
hexo d
- 測試
在地址欄中輸入項目名,直接進入博客
更換主題
自行搜索主題進行替換,此處演示yillia主題替換:
- 克隆主題
git clone https://www.github.com/litten/hexo-theme-yilia.git themes/yilia
- 替換
hexo clean && hexo d
再推薦兩個主題:
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
https://github.com/nexmoe/hexo-theme-nexmoe (自用)
主題集合:
https://hexo.io/themes/
還有一個安卓風格主題:
cd themes
git clone https://github.com/viosey/hexo-theme-material.git material
cd material
git checkout {branch/tags name}
注意:如果有需要,把主題文件夾內的config文件名重命名一下!去掉templete
以上三個主題全部fork到了我的gitee倉庫中,提升下載速度。主題安裝方式和配置參考各自主題的文檔
注意此處有坑:
如果採用Gitee託管的話,進入托管的倉庫->設置Gitee Pages服務,若綁定域名需要升級Gitee Pro,普通版每次更新要進行手動更新!!!
具體參考:https://gitee.com/help/articles/4136
github 需要使用域名才能進行訪問,我購買了xiaopi3.fun這個域名,需要在該項目的設置中的domain設置那裏填入自己的域名,並啓用https
hexo默認解析md有可能會有奇怪的bug,需要先本地預覽看看自己調一下
hexo 歸檔有問題,與某個分頁參數有影響,需要取消該參數:
# Pagination ## Set per_page to 0 to disable pagination per_page: 0 pagination_dir: page
實測不影響分頁,同時歸檔顯示不全問題解決
摺疊文章使用:<!--more-->
當md文件中存在: {{ }}
or {% %}
將會被轉義導致錯誤,使用下面的方式來處理:
由於無法正常顯示,故只能這樣顯示出來{% raw %}Hello {{ sensitive }}{% endraw %}