hexo博客

在新機器上部署hexo

環(huán)境

C:\Users\黃壯壯>node -v
v10.14.2
C:\Users\黃壯壯>npm -v
6.4.1
$ git --version
git version 2.20.1.windows.1
  • hexo

npm install hexo -g块请,開始安裝Hexo

建立hexo項目

在制定文件夾下初始化hexo項目

hexo init

初始化信息

D:\blog_hexo>hexo init
INFO  Cloning hexo-starter to D:\blog_hexo
Cloning into 'D:\blog_hexo'...
remote: Enumerating objects: 68, done.
remote: Total 68 (delta 0), reused 0 (delta 0), pack-reused 68
Unpacking objects: 100% (68/68), done.
Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
Cloning into 'D:/blog_hexo/themes/landscape'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 867 (delta 8), reused 5 (delta 1), pack-reused 846
Receiving objects: 100% (867/867), 2.55 MiB | 155.00 KiB/s, done.
Resolving deltas: 100% (457/457), done.
Submodule path 'themes/landscape': checked out '73a23c51f8487cfcd7c6deec96ccc7543960d350'
?[32mINFO ?[39m Install dependencies
npm WARN deprecated titlecase@1.1.2: no longer maintained
npm WARN deprecated postinstall-build@5.0.3: postinstall-build's behavior is now built into npm! You should migrate off of postinstall-build and use the new `prepare` lifecycle script with npm 5.0.0 or greater.

> nunjucks@3.1.6 postinstall D:\blog_hexo\node_modules\nunjucks
> node postinstall-build.js src

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 422 packages from 501 contributors and audited 4700 packages in 19.884s
found 0 vulnerabilities

INFO  Start blogging with Hexo!

hexo與gitee page建立連接

  • 設置Git的username與email
D:\blog_hexo>git config --global user.name "Q10Viking"

D:\blog_hexo>git config --global user.email "1193094618@qq.com"
  • 生成密鑰

會創(chuàng)建.ssh文件夾棋蚌,制定我們要生成的文件名
Enter file in which to save the key (/c/Users/黃壯壯/.ssh/id_rsa): /c/Users/黃壯壯/.ssh/gitee_id_rsa

$ ssh-keygen -t rsa -C "1193094618@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/黃壯壯/.ssh/id_rsa): /c/Users/黃壯壯/.ssh/gitee_id_rsa
Created directory '/c/Users/黃壯壯/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/黃壯壯/.ssh/gitee_id_rsa.
Your public key has been saved in /c/Users/黃壯壯/.ssh/gitee_id_rsa.pub.
The key fingerprint is:
SHA256:6iYxI/Zn6R2/ErZtJAaTqJ6auwKpLOHX6wkmvfL4A+g 1193094618@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|     . .         |
|    . +          |
|.. .   oS        |
|=.= +  .= .      |
|*=.B.+.+.*       |
|+E*o=o*.ooo      |
|B==+oX+ .oo.     |
+----[SHA256]-----+

  • 在gitee中的Q10Viking項目中添加公鑰

  • 問題解決

問題: git@gitee.com: Permission denied (publickey)

添加密鑰到ssh-agent
eval "$(ssh-agent -s)"
添加生成的SSH key到ssh-agent
ssh-add ~/.ssh/gitee_id_rsa

過程

黃壯壯@LAPTOP-4K4RIFUD MINGW64 ~/.ssh
$ ssh -T  git@gitee.com
git@gitee.com: Permission denied (publickey).

黃壯壯@LAPTOP-4K4RIFUD MINGW64 ~/.ssh
$ eval "$(ssh-agent -s)"
Agent pid 8060

黃壯壯@LAPTOP-4K4RIFUD MINGW64 ~/.ssh
$ ssh-add ~/.ssh/gitee_id_rsa
Identity added: /c/Users/黃壯壯/.ssh/gitee_id_rsa (1193094618@qq.com)

黃壯壯@LAPTOP-4K4RIFUD MINGW64 ~/.ssh
$ ssh -T  git@gitee.com
Hi Q10Viking! You've successfully authenticated, but GITEE.COM does not provide shell access.
  • deploy

error

D:\blog_hexo>hexo d -g
... ...

git@gitee.com: 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
Error: git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.<anonymous> (D:\blog_hexo\node_modules\hexo-util\lib\spawn.js:37:17)
    at ChildProcess.emit (events.js:182:13)
    at ChildProcess.cp.emit (D:\blog_hexo\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:610:12)

$ ssh -T git@gitee.com
Hi Anonymous! You've successfully authenticated, but GITEE.COM does not provide shell access.
Note: Perhaps the current use is DeployKey.
Note: DeployKey only supports pull/fetch operations
  • 解決

在博客blog_hexo文件下將密鑰添加到ssh-agent中

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ ssh -T git@gitee.com
git@gitee.com: Permission denied (publickey).

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ eval "$(ssh-agent -s)"
Agent pid 15248

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ ssh-add ~/.ssh/gitee_id_rsa
Identity added: /c/Users/黃壯壯/.ssh/gitee_id_rsa (1193094618@qq.com)

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ ssh -T git@gitee.com
Hi Q10Viking! You've successfully authenticated, but GITEE.COM does not provide shell access.

在git bash中運行腰奋,不要再cmd中

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ hexo d -g
INFO  Start processing
INFO  Files loaded in 83 ms
... ...
On branch master
nothing to commit, working tree clean
remote: Powered By Gitee.com
Branch 'master' set up to track remote branch 'master' from 'git@gitee.com:q10viking/Q10Viking.git'.
To gitee.com:q10viking/Q10Viking.git
 + a714c32...8f1302b HEAD -> master (forced update)
INFO  Deploy done: git

hexo項目于git關聯(lián)后

為github遷移到gitee做準備

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true

添加了git信息

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[branch "master"]
    remote = git@gitee.com:q10viking/Q10Viking.git
    merge = refs/heads/master
deploy:
  type: git
  repository: git@gitee.com:q10viking/Q10Viking.git
  branch: master

Next主題

下載主題

下載到hexo項目下的 themes/next 中

黃壯壯@LAPTOP-4K4RIFUD MINGW64 /d/blog_hexo
$ git clone https://github.com/theme-next/hexo-theme-next themes/next
Cloning into 'themes/next'...
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 4785 (delta 12), reused 22 (delta 11), pack-reused 4754
Receiving objects: 100% (4785/4785), 4.91 MiB | 87.00 KiB/s, done.
Resolving deltas: 100% (2891/2891), done.

使用主題

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
## theme: landscape
theme: next

遷移

  • 從github遷移到gitee
  • 從舊電腦遷移到新電腦
  1. github->gitee遷移在新電腦上按上面配置好環(huán)境冲杀,新建一個hexo項目疙教,此時使用的git的倉庫使用gitee的器紧,這樣這個項目就會提交到我們建立在gitee的倉庫中容贝。主要涉及兩個文件關于git

_config.yml

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: git@gitee.com:q10viking/Q10Viking.git
  branch: master

.deploy_git.git\config

[branch "master"]
    remote = git@gitee.com:q10viking/Q10Viking.git
    merge = refs/heads/master
  1. 舊電腦-->新電腦遷移在將舊電腦的next主題的所有文件拷貝過來自脯,放在themes目錄下(任然使用Next主題),將sources目錄下的文件(我們寫的文章)復制到新電腦對應的目錄

圖床

  • 在hexo項目下的source目錄下新建一個imgs文件用來存儲圖片

  • 使用Typora編輯器嗤疯,用相對路徑加載圖片

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末冤今,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子茂缚,更是在濱河造成了極大的恐慌戏罢,老刑警劉巖屋谭,帶你破解...
    沈念sama閱讀 211,123評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異龟糕,居然都是意外死亡桐磁,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評論 2 384
  • 文/潘曉璐 我一進店門讲岁,熙熙樓的掌柜王于貴愁眉苦臉地迎上來我擂,“玉大人,你說我怎么就攤上這事缓艳⌒DΓ” “怎么了?”我有些...
    開封第一講書人閱讀 156,723評論 0 345
  • 文/不壞的土叔 我叫張陵阶淘,是天一觀的道長衙吩。 經(jīng)常有香客問我,道長溪窒,這世上最難降的妖魔是什么坤塞? 我笑而不...
    開封第一講書人閱讀 56,357評論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮澈蚌,結(jié)果婚禮上摹芙,老公的妹妹穿的比我還像新娘。我一直安慰自己宛瞄,他們只是感情好浮禾,可當我...
    茶點故事閱讀 65,412評論 5 384
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著坛悉,像睡著了一般伐厌。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上裸影,一...
    開封第一講書人閱讀 49,760評論 1 289
  • 那天,我揣著相機與錄音军熏,去河邊找鬼轩猩。 笑死,一個胖子當著我的面吹牛荡澎,可吹牛的內(nèi)容都是我干的均践。 我是一名探鬼主播,決...
    沈念sama閱讀 38,904評論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼摩幔,長吁一口氣:“原來是場噩夢啊……” “哼彤委!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起或衡,我...
    開封第一講書人閱讀 37,672評論 0 266
  • 序言:老撾萬榮一對情侶失蹤焦影,失蹤者是張志新(化名)和其女友劉穎车遂,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體斯辰,經(jīng)...
    沈念sama閱讀 44,118評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡舶担,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,456評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了彬呻。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片衣陶。...
    茶點故事閱讀 38,599評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖闸氮,靈堂內(nèi)的尸體忽然破棺而出剪况,到底是詐尸還是另有隱情,我是刑警寧澤蒲跨,帶...
    沈念sama閱讀 34,264評論 4 328
  • 正文 年R本政府宣布拯欧,位于F島的核電站,受9級特大地震影響财骨,放射性物質(zhì)發(fā)生泄漏镐作。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,857評論 3 312
  • 文/蒙蒙 一隆箩、第九天 我趴在偏房一處隱蔽的房頂上張望该贾。 院中可真熱鬧,春花似錦捌臊、人聲如沸杨蛋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,731評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽逞力。三九已至,卻和暖如春糠爬,著一層夾襖步出監(jiān)牢的瞬間寇荧,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,956評論 1 264
  • 我被黑心中介騙來泰國打工执隧, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留揩抡,地道東北人。 一個月前我還...
    沈念sama閱讀 46,286評論 2 360
  • 正文 我出身青樓镀琉,卻偏偏與公主長得像峦嗤,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子屋摔,可洞房花燭夜當晚...
    茶點故事閱讀 43,465評論 2 348

推薦閱讀更多精彩內(nèi)容