在新機器上部署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
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
- 從舊電腦遷移到新電腦
- github->gitee遷移在新電腦上按上面配置好環(huán)境冲杀,新建一個hexo項目疙教,此時使用的git的倉庫使用gitee的器紧,這樣這個項目就會提交到我們建立在gitee的倉庫中容贝。主要涉及兩個文件關于git
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: git@gitee.com:q10viking/Q10Viking.git
branch: master
[branch "master"]
remote = git@gitee.com:q10viking/Q10Viking.git
merge = refs/heads/master
- 舊電腦-->新電腦遷移在將舊電腦的next主題的所有文件拷貝過來自脯,放在themes目錄下(任然使用Next主題),將sources目錄下的文件(我們寫的文章)復制到新電腦對應的目錄
圖床
在hexo項目下的source目錄下新建一個imgs文件用來存儲圖片
使用Typora編輯器嗤疯,用相對路徑加載圖片