hexo问题

记录一下维护hexo博客时遇到的问题

spawn failed

1
2
3
4
5
6
7
8
Connection to github.com closed by remote host.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:xxxxx/xxxxx.github.io.git'
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (/home/pi/blog/node_modules/_hexo-util@0.6.3@hexo-util/lib/spawn.js:52:19)
at ChildProcess.emit (events.js:182:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)

这个错误是因为本地的博客版本与远程的版本不一致,解决方法是删除博客目录下的.deploy_git文件夹,然后克隆远程(也就是将要发布的地址)的仓库到博客目录里面,然后改名字为.deploy_git,另外一个不那么绕的办法是把远端仓库删除,删除本地的.deploy_git,再次发布,不过这样做会导致之前的提交记录丢失。

主页面无法正常加载

发现本地和 github 上面的博客都不能正常加载了,于是看了看控制台,发现 js 加载出现了问题,如下:

1
2
3
指向“https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js”的 <script> 加载失败
指向“https://cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js”的 <script> 加载失败。
指向“https://cdn.bootcss.com/require.js/2.2.0/require.min.js”的 <script> 加载失败。

访问一下,发现是cdn.bootcss.com的证书出现了问题导致无法正常访问,这时我们只需要把他换个源就好

即把cdn.bootcss.com换成cdnjs.cloudflare.com/ajax/libs,操作如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS F:\Blog\themes\yelee> findstr.exe /s "cdn.boot" *
layout\_partial\head.ejs: <link href="//cdn.bootcss.com/pace/1.0.2/themes/<%= theme.progressBar.color || 'blue'%>/pace-theme-<%= theme.progressBar.type || 'minimal'%>.css" rel="stylesheet">
source\css\_partial\customise\social-icon.styl: background url(//cdn.bootcss.com/logos/0.2.0/github-octocat.svg) no-repeat white
source\css\_partial\customise\social-icon.styl: background url(//cdn.bootcss.com/logos/0.2.0/codepen-icon.svg) no-repeat black
_config.yml: jquery: //cdn.bootcss.com/jquery/2.2.4/jquery.min.js
_config.yml: require: //cdn.bootcss.com/require.js/2.2.0/require.min.js
_config.yml: fontawesome: //cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css
_config.yml: fancybox_js: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js
_config.yml: fancybox_css: //cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css
_config.yml: animate_css: //cdn.bootcss.com/animate.css/3.5.1/animate.min.css
_config.yml: jquery_ui_js: //cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js
_config.yml: jquery_ui_css: //cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css
_config.yml: pace_js: //cdn.bootcss.com/pace/1.0.2/pace.min.js
_config.yml: clipboard: //cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js
_config.yml: mathjax: //cdn.bootcss.com/mathjax/2.6.1/MathJax.js
_config.yml: scrollreveal: //cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js

ERROR Deployer not found: git

$ hexo d
ERROR Deployer not found: git

npm install --save hexo-deployer-git

换电脑后继承hexo

一、安装必要软件

安装 Git 客户端

安装 node JS

二、在 github 官网添加新电脑产生的密钥

参考我的另一篇文章:hexo上部署博客到Github失败

三、源文件拷贝

将你原来电脑上个人博客目录下必要文件拷到你的新电脑上(比如F:/Blog目录下),注意无需拷全部,只拷如下几个目录:

1
_config.yml package.json scaffolds/ source/ themes/

四、安装 hexo

在 cmd 下输入下面指令安装 hexo:

1
npm install hexo-cli -g

五、进入 F:/Blog 目录(你拷贝到新电脑的目录),输入下面指令安装相关模块

1
npm installnpm install hexo-deployer-git --save  // 文章部署到 git 的模块(下面为选择安装)npm install hexo-generator-feed --save  // 建立 RSS 订阅npm install hexo-generator-sitemap --save // 建立站点地图

六、测试

这时候使用 hexo s 基本可以看到你新添加的文章了。

七、部署发布文章

1
hexo clean   // 清除缓存 网页正常情况下可以忽略此条命令hexo g       // 生成静态网页hexo d       // 开始部署

八、Github 添加 SSH Keys

首先在本地创建 SSH Keys:

$ ssh-keygen -t rsa -C “wujiajiansh@163.com

后面的邮箱即为 github 注册邮箱,也是你登录 Github 的邮箱,之后会要求确认路径和输入密码,一路回车就行。

成功的话会在 ~/下生成 .ssh文件夹,进去,打开 id_rsa.pub,复制里面的key即可。

img

输入 eval “$(ssh-agent -s)” ,添加密钥到ssh-agent,再输入 ssh-add ~/.ssh/id_rsa ,添加生成的SSH key到ssh-agent

1
JaJian@DESKTOP-H2C0ES1 MINGW64 /d/hexo$ eval "$(ssh-agent -s)"Agent pid 5516JaJian@DESKTOP-H2C0ES1 MINGW64 /d/hexo$ ssh-add ~/.ssh/id_rsaIdentity added: /c/Users/JaJian/.ssh/id_rsa (/c/Users/JaJian/.ssh/id_rsa)JaJian@DESKTOP-H2C0ES1 MINGW64 /d/hexo$ clip < ~/.ssh/id_rsa.pub

然后我们再次测试下公钥有没有添加成功:ssh -T git@github.com

1
JaJian@DESKTOP-H2C0ES1 MINGW64 /d/hexo$ ssh -T git@github.comThe authenticity of host 'github.com (13.229.188.59)' can't be established.RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.Hi noobgod! You've successfully authenticated, but GitHub does not provide shell access.

成功了。

之后我们再次部署我们的博客网站:hexo d

转自 >https://www.cnblogs.com/study-everyday/p/8902136.html#autoid-2-4-0

npm安装hexo速度过慢

npm官方源在国内的下载速度极其慢,用官网的npm install hexo-cli -g速度非常感人,所以不推荐这种方式。这里我推荐用淘宝的npm分流——cnpm
安装过程很简单:
npm install -g cnpm --registry=https://registry.npm.taobao.org
然后等着装完即可,之后的用法和npm一样,无非是把npm install改成cnpm install,但是速度比之前快了不止一个数量级

文章目录
  1. 1. spawn failed
  2. 2. 主页面无法正常加载
  3. 3. ERROR Deployer not found: git
  4. 4. 换电脑后继承hexo
    1. 4.1. 一、安装必要软件
    2. 4.2. 二、在 github 官网添加新电脑产生的密钥
    3. 4.3. 三、源文件拷贝
    4. 4.4. 四、安装 hexo
    5. 4.5. 五、进入 F:/Blog 目录(你拷贝到新电脑的目录),输入下面指令安装相关模块
    6. 4.6. 六、测试
    7. 4.7. 七、部署发布文章
    8. 4.8. 八、Github 添加 SSH Keys
  5. 5. npm安装hexo速度过慢
|