查找資料的時候發現了next這個博客主題,next!非常的漂亮,順手查看了hexo的相關部署。
Hexo官方介紹
Hexo 是一個快速、簡潔且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在幾秒內,即可利用靚麗的主題生成靜態網頁。
官網 https://hexo.io/zh-cn/docs/index.html
Hexo博客建立
簡潔高效,如同官網的介紹。安裝過程非常簡單,官網有非常詳細的文檔,安裝文檔;並且還是中文的哦!
部署至github
安裝完成后需要部署至github,根據官網的介紹,首先進行配置
安裝hexo-delopyer-git
安裝hexo關於git管理組件:hexo-delopyer-git,照着做即可
修改配置文件
找到根目錄下的_config.yml,修改配置
deploy:
type: git
repo: https://github.com/pyrinelaw/pyrinelaw.github.io.git
branch: master
上傳操作
hexo d
報錯spawn git ENOENT
Error: spawn git ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20)
at process._tickCallback (node.js:355:11)
未添加Git環境變量引起,添加Git與git管理庫的環境變量即可;
D:\Git\bin;D:\Git\libexec\git-core
設置完畢后強制更新環境變量,或者重啟電腦~
讀取不到Git分支
Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io
cs/troubleshooting.html
Error: fatal: 'github.com/pyrinelaw/pyrinelaw.github.io.git' does not appear
be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
讀取不到github上的分支,使用Hexo之前是有使用Git操作過Github的,所以不大可能是Git安裝的問題。
ssh -v git@github.com
顯示ssh連接github成功,說明Git安裝正確。
卸載Git重新安裝,錯誤繼續出現。擱置了一天,中午午休的時候網上逛論壇,發現了此問題。原來是我的Git版本太新的緣故。。。
卸載Git 2.5版本,安裝1.9版本,問題解決-_-
Git提交錯誤
再次部署
hexo d
提示success ~
但是尼瑪,居然把整個hexo根目錄給提交了上去,這不是我要的結果啊,說好的只提交public文件夾的呢!@Д@
查看hexo根目錄,存在“.git”這個目錄,原來是在hexo根目錄下,我進行過git init的操作,刪除“.git”文件夾即可。
至此博客已部署至Github完畢
貼上地址: pyrinelaw.github.io
附:相關查找資料
https://hexo.io/zh-cn/docs/
http://artori.us/git-github-usage/
http://www.jianshu.com/p/858ecf233db9
http://www.cognize.me/2015/08/22/msysgiterror/