背景
sphinx要用rst格式編寫,感覺有些麻煩,正好看見用hexo編寫博客,直接可以使用md格式,更方便快捷。(更新一下:我又用回sphinx了😂,大家想學hexo,可以看我這個簡易版教材,再直接參考鏈接裏面cloudy。想了解sphinx,點這)
兩者區別是,hexo偏向blog,就和csdn很像,一篇一篇的書寫,sphinx像寫一本書,或者說一個主題相關的內容
操作
安裝hexo
-
全局安裝hexo(命令行)
$ npm install -g hexo-cli
-
創建項目
hexo init blog
-
啓動項目
hexo s
添加內容
-
按官網走
hexo new "My New Post" hexo s
切換主題
-
選擇主題
-
主題複製到本地
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
-
修改本地文件_congif.yml,大家可以直接看主題作者的readme.txt文檔
theme: yilia
-
先清除緩存文件 (db.json) 和已生成的靜態文件。再重新生成靜態文件,最後部署
hexo clean hexo g hexo s
上傳到github並且發佈
-
安裝插件幫忙推送到github
npm install hexo-deployer-git --save
-
修改_congif.yml
deploy: type: git repo: https://github.com/xxxxxxxxx(github倉庫地址) branch: master
-
部署
hexo clean hexo g hexo deploy
-
打開github->setting->Github Pages->master,遇到問題了
4.1 一直404
等5分鐘,還是沒反應,就本地添加文件再次上傳(hexo clean&&hexo deploy)4.2 頁面出來了沒有主題,報下面的錯
去_config.yml底下修改
url: 你的github pages的鏈接
root: /blog
還有添加jsonContent的內容缺失模塊。 1、請確保node版本大於6.2 2、在博客根目錄(注意不是yilia根目錄)執行以下命令: npm i hexo-generator-json-content --save 3、在根目錄_config.yml裏添加配置: jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true
-
推薦想使用hexo的多看看這個文檔,非常詳細記錄了你將遇到的坑cloudy
參考連接
[1]https://hexo.io/zh-cn/docs/commands.html
[2]https://zhuanlan.zhihu.com/p/98427357
[3]https://github.com/litten/hexo-theme-yilia
[4]https://www.jianshu.com/p/390f202c5b0e
[5]https://blog.csdn.net/qq_29347295/article/details/79005154
[6]cloudy