hexo博客

在新机器上部署hexo

环境

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"
  • 生成密钥

会创建.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关联后

为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迁移在新电脑上按上面配置好环境,新建一个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编辑器,用相对路径加载图片

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,590评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 86,808评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,151评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,779评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,773评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,656评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,022评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,678评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,038评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,659评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,756评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,411评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,005评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,973评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,053评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,495评论 2 343

推荐阅读更多精彩内容