下個(gè)月開(kāi)始要準(zhǔn)備找工作了狰腌,所以最近需要建個(gè)博客除破,這樣到時(shí)候面試就可以show一手啦。但素呢琼腔,特喵的9宸恪!!hexo+github搭建光坝,可以說(shuō)非常簡(jiǎn)單尸诽,也可以說(shuō)是非常難。整整用了我兩天的時(shí)間盯另,所以我必須要記錄一下性含。免得以后再次出錯(cuò)忘記怎么弄了。
【此教程默認(rèn)已安裝git Bash鸳惯,nodejs商蕴,且已注冊(cè)github,并綁定ssh key】
正常模式(對(duì)于電腦第一次安裝部署hexo的)
- 在github上創(chuàng)建一個(gè)倉(cāng)庫(kù)绪商,名字為
silvia-YQY.github.io
可默認(rèn)添加README.md
- 電腦安裝hexo
$ npm install hexo-cli -g //全局安裝hexo客戶端
$ hexo init blog //創(chuàng)建一個(gè)blog的文件夾,并且hexo初始化改文件夾
$ cd blog //進(jìn)入blog文件夾
$ npm install //安裝hexo需要的包
$ hexo server //打開(kāi)hexo服務(wù)器后德,默認(rèn)端口為4000部宿;
此時(shí)本地的hexo已經(jīng)部署完畢,在瀏覽器搜索 : http://localhost:4000瓢湃,已經(jīng)可以查看博客
- 部署hexo到github上面
- 安裝hexo-deployer-git
$ npm install hexo-deployer-git --save
- 修改blog文件夾下面的yml文件
deploy:
type: git
repo: git@github.com:silvia-YQY/silvia-YQY.github.io.git
branch: master
message: blog
- 重新生成并部署
$ hexo generate
$ hexo deploy
注:無(wú)須將blog文件夾里面安裝silvia-YQY.github.io倉(cāng)庫(kù)的文件夾內(nèi)理张,而且無(wú)須git push 上傳。只需要安裝hexo-deployer-git绵患,并運(yùn)行hexo deploy 雾叭,該插件會(huì)自動(dòng)將文件部署到silvia-YQY.github.io倉(cāng)庫(kù)內(nèi)。
切記B潋V!不要把hexo的blog文件夾復(fù)制過(guò)去silvia-YQY.github.io倉(cāng)庫(kù)筏勒,silvia-YQY.github.io倉(cāng)庫(kù)無(wú)須操作任何事情R破取!管行!血的教訓(xùn)
此時(shí)本地的hexo已經(jīng)在github部署完畢厨埋,在瀏覽器搜索 : https://silvia-yqy.github.io,已經(jīng)可以查看博客
此為不知道為何會(huì)出問(wèn)題的解決辦法
由于之前在家里弄捐顷,全部已經(jīng)部署完畢了荡陷,并且可以正常運(yùn)行。但是更新文章的時(shí)候迅涮,可能是手賤废赞,上傳文件上傳錯(cuò)了,而且自己也傻逼的把文件復(fù)制過(guò)去倉(cāng)庫(kù)了叮姑,所以唉地,哎~
- hexo deploy 錯(cuò)誤
nothing to commit, working directory clean
Permission denied (publickey).
fatal: Could not read from remote repository.
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/docs/troubleshooting.html](http://hexo.io/docs/troubleshooting.html)
Error: Permission denied (publickey). // 此為重點(diǎn)!!T稀屠尊!
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
該錯(cuò)誤,跟著官方文檔做就好耕拷。
在hexo文件夾內(nèi)進(jìn)行一下操作,期間若需要輸入密碼讼昆,就輸入密碼吧
- 1.1
sh -T git@github.com
沒(méi)出錯(cuò)后
- 1.2
eval "$(ssh-agent -s)"
正確應(yīng)該為
$ ssh -T git@github.com
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
Hi silvia-YQY! You've successfully authenticated, but GitHub does not provide shell access.
- 1.3
$ eval "$(ssh-agent -s)"
Agent pid 2556
- 1.4
$ ssh-add -l -E md5
4096 MD5:7a:fa:c3:4e:cf:1a:91:b7:d0:5d:45:79:90:b4:d8:03 /c/Users/Administrator/.ssh/id_rsa (RSA)
下面的md5碼出現(xiàn)為正常,若出現(xiàn)一下情況
The agent has no identities.
則先去C:\Users\Administrator.ssh刪除known_hosts文件骚烧,然后運(yùn)行
$ ssh-add ~/.ssh/id_rsa
此為正確信息
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/Administrator/.ssh/id_rsa:
Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa)
正確后浸赫,再次運(yùn)行
$ ssh-add -l -E md5
出現(xiàn)md5碼為一斤綁定權(quán)限成功。
此時(shí)可以順利的 $ hexo deploy