Hexo-NexT博客问题汇总

引言

本文对Hexo博客+NexT主题使用中出现的各种问题进行总结,方便读者解决这些遇到的相同问题。

博文生成失败

问题描述

问题起源于一次博文的生成:

hexo new RT2

之后对博文的配置信息进行了简单的填写:

title: Ray Tracing: The Next Week
comment: false
date: 2021-07-30 00:42:59
type:
tags:
- Computer Graphics
- Ray Tracing
categories: 光线追踪 (Ray Tracing)
banner_img:
index_img:
abbrlink:
translate_title:
top:
mathjax:

之后打算 hexo 三连:

hexo clean && hexo g && hexo d

但是出现了报错:

ERROR {
err: YAMLException: incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 1, column 19:
title: Ray Tracing: The Next Week
^
at generateError (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
at throwError (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
at readBlockMapping (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1027:9)
at composeNode (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
at readDocument (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1525:3)
at loadDocuments (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1588:5)
at Object.load (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1614:19)
at parseYAML (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/lib/front_matter.js:69:23)
at parse (/Users/apple/Desktop/blog/node_modules/hexo-front-matter/lib/front_matter.js:50:12)
at /Users/apple/Desktop/blog/node_modules/hexo/lib/plugins/processor/post.js:51:20
at tryCatcher (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:544:35)
at Promise._settlePromise (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:673:18)
at PromiseArray._resolve (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:127:19)
at PromiseArray._promiseFulfilled (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:145:14)
at PromiseArray._iterate (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:115:31)
at PromiseArray.init [as _init] (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:79:10)
at Promise._settlePromise (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:601:21)
at Promise._settlePromise0 (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:673:18)
at PromiseArray._resolve (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:127:19)
at PromiseArray._promiseFulfilled (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise_array.js:145:14)
at Promise._settlePromise (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:609:26)
at Promise._settlePromise0 (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/apple/Desktop/blog/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21) {
reason: 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line',
mark: Mark {
name: null,
buffer: 'title: Ray Tracing: The Next Week\n' +
'comment: false\n' +
'date: 2021-07-30 00:42:59\n' +
'type:\n' +
'tags:\n' +
' - Computer Graphics\n' +
' - Ray Tracing\n' +
'categories: 光线追踪 (Ray Tracing)\n' +
'banner_img:\n' +
'index_img:\n' +
'abbrlink:\n' +
'translate_title:\n' +
'top:\n' +
'mathjax:\n' +
'\x00',
position: 18,
line: 0,
column: 18
}
}
} Process failed: %s _posts/RT2.md

解决方案

报错信息提示的很明确,原因是我们的标题出现了 : 造成文章无法正常生成,去掉即可:

-title: Ray Tracing: The Next Week
+title: Ray Tracing The Next Week
comment: false
date: 2021-07-30 00:42:59
type:
tags:
- Computer Graphics
- Ray Tracing
categories: 光线追踪 (Ray Tracing)
banner_img:
index_img:
abbrlink:
translate_title:
top:
mathjax:

标签云回滚

问题描述

在部分页面在下拉过程会出现回滚情况,导致无法到达底部。最开始是在标签页发现的,几次测试还具有一定的随机性,在Chrome上。在手机端因为不显示sidebar所以没有这个问题。

解决方案

注释掉标签云:

-      {% if site.tags.length > 1 %}
- <script type="text/javascript" charset="utf-8" src="{{ url_for('/js/tagcloud.js') }}"></script>
- <script type="text/javascript" charset="utf-8" src="{{ url_for('/js/tagcanvas.js') }}"></script>
- <div class="widget-wrap">
- <h5 class="widget-title"></h5>
- <div id="myCanvasContainer" class="widget tagcloud">
- <canvas width="250" height="250" id="resCanvas" style="width:100%">
- {{ list_tags() }}
- </canvas>
- </div>
- </div>
- {% endif %}

Pjax刷新

问题描述

在使用音乐播放器Aplayer与说说Artitalk时发现必须刷新两次才能加载出来。

解决方案

最开始尝试在这几个页面不使用pjax:

pjax: ture  
exclude:
- '/about/'
- '/artitalk/'

但问题并没有解决,第一次刷新还是什么也没有,需要再次刷新才显示内容。

目前没有两全其美的办法,对于页面间跳转我的需求并不是很高,所以在主题配置文件中关闭了pjax选项,音乐播放器与Artitalk均恢复正常。

# Easily enable fast Ajax navigation on your website.
# Dependencies: https://github.com/theme-next/theme-next-pjax
- pjax: ture
+ pjax: false

后面加入Artitalk的交流群询问是否兼容pjax,得到的答案是不行。在关闭pjax后页面间跳转明显变慢,后面又查询了一下找到一种折中的办法:pjax页面刷新两次。在themes/layout/pjax.swig中加入刷新代码:

<script>
var pjax = new Pjax({
selectors: [
'head title',
'#page-configurations',
'.content-wrap',
'.post-toc-wrap',
'.languages',
'#pjax'
],
switches: {
'.post-toc-wrap': Pjax.switches.innerHTML
},
analytics: false,
cacheBust: false,
scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
var code = element.text || element.textContent || element.innerHTML || '';
var parent = element.parentNode;
parent.removeChild(element);
var script = document.createElement('script');
if (element.id) {
script.id = element.id;
}
if (element.className) {
script.className = element.className;
}
if (element.type) {
script.type = element.type;
}
if (element.src) {
script.src = element.src;
// Force synchronous loading of peripheral JS.
script.async = false;
}
if (element.dataset.pjax !== undefined) {
script.dataset.pjax = '';
}
if (code !== '') {
script.appendChild(document.createTextNode(code));
}
parent.appendChild(script);
});


NexT.boot.refresh();
+ loadMeting();
// Define Motion Sequence & Bootstrap Motion.
if (CONFIG.motion.enable) {
NexT.motion.integrator
.init()
.add(NexT.motion.middleWares.subMenu)
.add(NexT.motion.middleWares.postList)
.bootstrap();
}


NexT.utils.updateSidebarPosition();

+ $(document).ready(function () {
+ if(location.href.indexOf("#reloaded")==-1){
+ location.href=location.href+"#reloaded";
+ location.reload();
+ }
+ })

});
</script>

这样从某种程度保证了性能和花里胡哨,但刷新也无形中降低了性能,所以是把双刃剑取舍由读者来选择。但如果我们简单掉换一下顺序,在开头就重新刷新就没必要全部渲染完后再重新加载,性能提升了许多:

<script>
var pjax = new Pjax({
selectors: [
'head title',
'#page-configurations',
'.content-wrap',
'.post-toc-wrap',
'.languages',
'#pjax'
],
switches: {
'.post-toc-wrap': Pjax.switches.innerHTML
},
analytics: false,
cacheBust: false,
scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
+ $(document).ready(function () {

+ if(location.href.indexOf("#reloaded")==-1){
+ location.href=location.href+"#reloaded";
+ location.reload();
+ }
+})
#在这后面可以加入程序的其他代码


document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
var code = element.text || element.textContent || element.innerHTML || '';
var parent = element.parentNode;
parent.removeChild(element);
var script = document.createElement('script');
if (element.id) {
script.id = element.id;
}
if (element.className) {
script.className = element.className;
}
if (element.type) {
script.type = element.type;
}
if (element.src) {
script.src = element.src;
// Force synchronous loading of peripheral JS.
script.async = false;
}
if (element.dataset.pjax !== undefined) {
script.dataset.pjax = '';
}
if (code !== '') {
script.appendChild(document.createTextNode(code));
}
parent.appendChild(script);
});


NexT.boot.refresh();

// Define Motion Sequence & Bootstrap Motion.
if (CONFIG.motion.enable) {
NexT.motion.integrator
.init()
.add(NexT.motion.middleWares.subMenu)
.add(NexT.motion.middleWares.postList)
.bootstrap();
}

NexT.utils.updateSidebarPosition();

- $(document).ready(function () {
- if(location.href.indexOf("#reloaded")==-1){
- location.href=location.href+"#reloaded";
- location.reload();
- }
- })

});
</script>

版本控制

强烈建议无论是否以VSCode为主力编辑器都下载一个,它的git版本控制插件让我可以进行一些测试并以GUI可视化的方式回滚。

SSH失效

问题描述

kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/Users/apple/Desktop/Dev/blog/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

解决方案

cd ~
cd .ssh
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
cat id_rsa.pub

Font-Awesome 图标失效

问题描述

最近更新 NexT 主题的 Font-Awesome 图标失效了,还不是全部失效,是部分失效显示为空白。

解决方案

首先检查主题的 _config.yml 的 CDN:

# Internal version: 5.13.0
# fontawesome: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css
# fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css
fontawesome: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css

仔细观察,新版本使用的 Font-Awesome 和之前原来的 CDN 版本不一样,所以更改一下 CDN:

# Internal version: 4.7.0
# fontawesome: //cdn.jsdelivr.net/npm/font-awesome@4/css/font-awesome.min.css
# fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css
fontawesome: //cdn.jsdelivr.net/npm/font-awesome@4/css/font-awesome.min.css

再检查一下自己的图标:

# Social Links
# Usage: `Key: permalink || icon`
# Key is the link label showing to end users.
# Value before `||` delimiter is the target permalink, value after `||` delimiter is the name of Font Awesome icon.
social:
E-Mail: mailto:zoeyousa@gmail.com || fa fa-envelope
GitHub: https://github.com/Yousazoe || fab fa-github
Twitter: https://twitter.com/YousaZoe || fab fa-twitter
Weibo: https://www.weibo.com/6034231696/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1 || fab fa-weibo
Steam: https://steamcommunity.com/profiles/76561198856466228/ || fab fa-steam
Chess: https://www.chess.com/member/yousazoe || fab fa-chess-pawn
RSS: /atom.xml || fa fa-rss

#GitHub: https://github.com/yourname || github
#E-Mail: mailto:yourname@gmail.com || envelope
#Weibo: https://weibo.com/yourname || weibo
#Google: https://plus.google.com/yourname || google
#Twitter: https://twitter.com/yourname || twitter
#FB Page: https://www.facebook.com/yourname || facebook
#StackOverflow: https://stackoverflow.com/yourname || stack-overflow
#YouTube: https://youtube.com/yourname || youtube
#Instagram: https://instagram.com/yourname || instagram
#Skype: skype:yourname?call|chat || skype

可以发现失效的图标都是 fa fa-xxx 的形式,所以问题很可能是格式不一致,全部改成一样的即可:

# Social Links
# Usage: `Key: permalink || icon`
# Key is the link label showing to end users.
# Value before `||` delimiter is the target permalink, value after `||` delimiter is the name of Font Awesome icon.
social:
E-Mail: mailto:zoeyousa@gmail.com || fab fa-envelope
GitHub: https://github.com/Yousazoe || fab fa-github
Twitter: https://twitter.com/YousaZoe || fab fa-twitter
Weibo: https://www.weibo.com/6034231696/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1 || fab fa-weibo
Steam: https://steamcommunity.com/profiles/76561198856466228/ || fab fa-steam
Chess: https://www.chess.com/member/yousazoe || fab fa-chess-pawn
RSS: /atom.xml || fab fa-rss

#GitHub: https://github.com/yourname || github
#E-Mail: mailto:yourname@gmail.com || envelope
#Weibo: https://weibo.com/yourname || weibo
#Google: https://plus.google.com/yourname || google
#Twitter: https://twitter.com/yourname || twitter
#FB Page: https://www.facebook.com/yourname || facebook
#StackOverflow: https://stackoverflow.com/yourname || stack-overflow
#YouTube: https://youtube.com/yourname || youtube
#Instagram: https://instagram.com/yourname || instagram
#Skype: skype:yourname?call|chat || skype

版本升级指南

npm install -g hexo-cli
hexo version

npm install -g npm-check
npm-check

npm install -g npm-upgrade
npm-upgrade

npm update -g
npm install -g npm

hexo clean #清理hexo数据并重新生成页面并部署
hexo g -s
hexo d

经过以上这些命令,整体翻新就差不多了,theme的升级,我这边是删除了原来的主题目录,重新进行了拉取,注意保留配置文件,重新配置即可,就不详述了。

主题文件没有被追踪

问题描述

最近鼓捣自动化部署的时候发现自己的博客源码仓库的主题配置出现了问题,next-reloaded 文件(也就是我一直在使用的博客主题)似乎出现了问题怎么也打不开。

赶紧检查一下 git:

❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: .idea/workspace.xml
modified: themes/next-reloaded (modified content, untracked content)

no changes added to commit (use "git add" and/or "git commit -a")

解决方案

这种情况相当于作为子项目未被追踪,最有可能的就是子文件夹里没有把 .git 文件删除干净,但 IDE 并没有显示,所以回到控制台:

cd ..
ls
ls -a
rm -rf .git

果然有 .git 文件,删除掉就可以了。

但是提交的时候依旧没有主题文件,索性就把文件夹移出 themes/ 提交再移回来:

解决了……很魔幻。

Jsdelivr失效后的替换方案

问题描述

Jsdelivr 最近国内访问非常不稳定,站内包括 fontawesome、lazyload 等服务都依赖于此。因为请求超时所以显示为空白页面,但鼠标还是可以点击相应的链接。

解决方案

更改 CDN 为国内镜像源或者替换 cdn.jsdelivr.netfastly.jsdelivr.net

# Script Vendors. Set a CDN address for the vendor you want to customize.
# Be aware that you would better use the same version as internal ones to avoid potential problems.
# Remember to use the https protocol of CDN files when you enable https on your site.
vendors:
# Internal path prefix.
_internal: lib

# Internal version: 3.1.0
# anime: //cdn.jsdelivr.net/npm/animejs@3.1.0/lib/anime.min.js
anime:

# Internal version: 5.13.0
# fontawesome: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css
# fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css
fontawesome: //fastly.jsdelivr.net/npm/@fortawesome/fontawesome-free@5/css/all.min.css

# MathJax
# mathjax: //cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
mathjax: //lib.baomitu.com/mathjax/3.2.1/es5/tex-mml-chtml.js

# KaTeX
# katex: //cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css
# katex: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css
# copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js
# copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css
katex:
copy_tex_js:
copy_tex_css:

# Internal version: 0.2.8
# pjax: //cdn.jsdelivr.net/gh/theme-next/theme-next-pjax@0/pjax.min.js
pjax: //fastly.jsdelivr.net/gh/theme-next/theme-next-pjax@0/pjax.min.js
# //npm.elemecdn.com/pjax/pjax.min.js

# FancyBox
# jquery: //cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
# fancybox: //cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js
# fancybox_css: //cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css
jquery: //lib.baomitu.com/jquery/3.6.0/jquery.min.js
fancybox_css: //lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css
fancybox: //lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js

# Medium-zoom
# mediumzoom: //cdn.jsdelivr.net/npm/medium-zoom@1/dist/medium-zoom.min.js
mediumzoom:

# Lazyload
# lazyload: //cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js
# lazyload: //cdnjs.cloudflare.com/ajax/libs/lozad.js/1.14.0/lozad.min.js
lazyload: //fastly.jsdelivr.net/npm/lozad@1/dist/lozad.min.js

# Pangu
# pangu: //cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js
# pangu: //cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.min.js
pangu: //fastly.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js

# Quicklink
# quicklink: //cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js
quicklink:

# DisqusJS
# disqusjs_js: //cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js
# disqusjs_css: //cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css
disqusjs_js:
disqusjs_css:

# Valine
# valine: //cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js
# valine: //cdnjs.cloudflare.com/ajax/libs/valine/1.3.10/Valine.min.js
valine:

# Gitalk
# gitalk_js: //cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js
# gitalk_css: //cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css
gitalk_js:
gitalk_css:

# Algolia Search
# algolia_search: //cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js
# instant_search: //cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js
algolia_search:
instant_search:

# Mermaid
# mermaid: //cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js
# mermaid: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.4.8/mermaid.min.js
mermaid: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.4.8/mermaid.min.js

# Internal version: 1.2.1
# velocity: //cdn.jsdelivr.net/npm/velocity-animate@1/velocity.min.js
# velocity: //cdnjs.cloudflare.com/ajax/libs/velocity/1.2.1/velocity.min.js
# velocity_ui: //cdn.jsdelivr.net/npm/velocity-animate@1/velocity.ui.min.js
# velocity_ui: //cdnjs.cloudflare.com/ajax/libs/velocity/1.2.1/velocity.ui.min.js
velocity:
velocity_ui:

# Internal version: 1.0.2
# pace: //cdn.jsdelivr.net/npm/pace-js@1/pace.min.js
# pace: //cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js
# pace_css: //cdn.jsdelivr.net/npm/pace-js@1/themes/blue/pace-theme-minimal.css
# pace_css: //cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-minimal.min.css
pace:
pace_css:

# Internal version: 1.0.0
# three: //cdn.jsdelivr.net/gh/theme-next/theme-next-three@1/three.min.js
# three_waves: //cdn.jsdelivr.net/gh/theme-next/theme-next-three@1/three-waves.min.js
# canvas_lines: //cdn.jsdelivr.net/gh/theme-next/theme-next-three@1/canvas_lines.min.js
# canvas_sphere: //cdn.jsdelivr.net/gh/theme-next/theme-next-three@1/canvas_sphere.min.js
three:
three_waves:
canvas_lines: //fastly.jsdelivr.net/gh/bynotes/texiao/source/js/caidai.js # 动态彩带
canvas_sphere:

# Internal version: 1.0.0
# canvas_ribbon: //cdn.jsdelivr.net/gh/theme-next/theme-next-canvas-ribbon@1/canvas-ribbon.js
canvas_ribbon:

而图床只能祈祷还可以用,同时准备好更换为微博图床或是 SMMS。

Template Render Error

问题描述

在添加相册图片后上传自动部署,部署失败报错:

INFO  Validating config
INFO DPlayer.min.css is not found in this version of dplayer, skip it.
INFO Validating config
INFO DPlayer.min.css is not found in this version of dplayer, skip it.
INFO Start processing
INFO neat the css: /home/runner/work/HEXO-BLOG/HEXO-BLOG/source/_data/styles.styl [ 17.54% saved]
INFO neat the css: /home/runner/work/HEXO-BLOG/HEXO-BLOG/source/_data/variables.styl [ NaN% saved]
INFO Generate link [5b6e89b1] for post [source/_posts/GT12.md][ 记忆消散,思念永存--7 Years From Now ]
INFO Generated: categories [游戏追踪 (Game Tracker)] for post [source/_posts/GT12.md][ 记忆消散,思念永存--7 Years From Now ]
INFO Generate link [2a9244e8] for post [source/_posts/SHADER1.md][ ShaderToy教程 ]
INFO Generated: categories [null] for post [source/_posts/SHADER1.md][ ShaderToy教程 ]
FATAL {
err: Template render error: (unknown path)
TypeError: Cannot read property 'slice' of null
at Object._prettifyError (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/lib.js:36:11)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:563:19
at Template.root [as rootRenderFunc] (eval at _compile (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:69:3)
at Template.render (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:552:10)
at Environment.renderString (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:380:17)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/extend/tag.js:236:16
at tryCatcher (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.fromNode.Promise.fromCallback (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:209:30)
at Tag.render (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/extend/tag.js:235:20)
at Object.onRenderEnd (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/hexo/post.js:426:22)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/hexo/render.js:85:21
at tryCatcher (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21) {
cause: Template render error: (unknown path)
TypeError: Cannot read property 'slice' of null
at Object._prettifyError (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/lib.js:36:11)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:563:19
at Template.root [as rootRenderFunc] (eval at _compile (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:69:3)
at Template.render (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:552:10)
at Environment.renderString (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/nunjucks/src/environment.js:380:17)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/extend/tag.js:236:16
at tryCatcher (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.fromNode.Promise.fromCallback (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:209:30)
at Tag.render (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/extend/tag.js:235:20)
at Object.onRenderEnd (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/hexo/post.js:426:22)
at /home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/hexo/lib/hexo/render.js:85:21
at tryCatcher (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/home/runner/work/HEXO-BLOG/HEXO-BLOG/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21),
isOperational: true
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

解决方案

这个报错没有表明具体的出错位置,而是告诉我遇到了 Hexo 不可识别的符号:

之前的部署没有问题,看来是新加入的某些内容有问题,很快把问题锁定到了相册:


### 2022

#### Automatic

![](https://cdn.jsdelivr.net/gh/Yousazoe/uPic@main/uPic/img/pgwMqS.jpg)


#### School

{% grouppicture 3-3 %}

{% endgrouppicture %}

这里的 {% grouppicture 3-3 %} 里面没有内容导致的 Hexo 无法识别该标签从而渲染失败,删除即可。

.gitignore规则不生效

问题描述

在 git 中如果想忽略掉某个文件,不让这个文件提交到版本库中,可以使用修改根目录中 .gitignore 文件。把某些目录或文件加入忽略规则,按照上述方法定义后发现并未生效。

解决方案

原因是 .gitignore 只能忽略那些原来没有被追踪的文件,如果某些文件已经被纳入了版本管理中,则修改 .gitignore 是无效的。那么解决方法就是先把本地缓存删除(改变成未被追踪状态),然后再提交:

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

不蒜子与Live2D冲突

问题描述

博客底部的不蒜子统计会失效,查阅网络资料得知很可能是与看板娘插件不兼容导致的(原作者一个一个插件安装卸载解决问题的态度着实令人钦佩),而我的看板小猫长时间处于本地部署可以看到而部署到服务器就加载失败的状态。

解决方案

对不蒜子正常和非正常功能进行代码分析,发现不蒜子失效时显示 style="display: none;,正常状态是 style="display: inline;,下面我们来针对这一点进行修改:

  • 下载 不蒜子 到本地(以我为例则是 theme\next\source\js)并将 none 替换为 inline
  • 修改 themes/next-reloaded/layout/_third-party/statistics/busuanzi-counter.swig 的源码,将 none 替换为 inline
{%- if theme.busuanzi_count.enable %}
<div class="busuanzi-count">
- <script{{ pjax }} async src="js/busuanzi.pure.mini.js"></script>
+ <script{{ pjax }} async src="js/busuanzi.pure.mini.js"></script>

{%- if theme.busuanzi_count.total_visitors %}
- <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
+ <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: inline;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.total_visitors_icon }}"></i>
</span>
<span class="site-uv" title="{{ __('footer.total_visitors') }}">
<span id="busuanzi_value_site_uv"></span>
</span>
</span>
{%- endif %}

{%- if theme.busuanzi_count.total_visitors and theme.busuanzi_count.total_views %}
<span class="post-meta-divider">|</span>
{%- endif %}

{%- if theme.busuanzi_count.total_views %}
- <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
+ <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: inline;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.total_views_icon }}"></i>
</span>
<span class="site-pv" title="{{ __('footer.total_views') }}">
<span id="busuanzi_value_site_pv"></span>
</span>
</span>
{%- endif %}
</div>
{%- endif %}

而 Live2D 的问题则是我在更新插件版本之后没有更新模型,所以显示不出来(不过报错信息真的很不友好)。

cnpm install --save live2d-widget-model-hijiki     

下载好之后会在 blog/node_modules/live2d-widget-model-hijiki 中:

既然无法加载模型那应该是配置出了问题,查阅文档后把博客根目录的配置模型位置改为了 lib/live2d_models/yourmodel(记得先拷贝到这个文件夹下!):

# Live2D
## https://github.com/EYHN/hexo-helper-live2d
live2d:
enable: true
scriptFrom: https://img.yousazoe.top/live2dw/lib/L2Dwidget.min.js
pluginRootPath: live2dw/
pluginJsPath: lib/
pluginModelPath: assets/
tagMode: false
debug: false
model:
- use: live2d-widget-model-hijiki
+ use: ./lib/live2d_models/live2d-widget-model-hijiki
display:
position: right
width: 100
height: 200
mobile:
show: true

use: 后如果直接输入模型名称(像我之前失效的那样)找的是 blog/live2d_models/...,换成了相对路径问题解决。标准完整并且注释非常详细的对比配置文件如下:

# Live2D
## https://github.com/EYHN/hexo-helper-live2d
live2d:
enable: true
# enable: false
scriptFrom: local # 默认
pluginRootPath: live2dw/ # 插件在站点上的根目录(相对路径)
pluginJsPath: lib/ # 脚本文件相对与插件根目录路径
pluginModelPath: assets/ # 模型文件相对与插件根目录路径
# scriptFrom: jsdelivr # jsdelivr CDN
# scriptFrom: unpkg # unpkg CDN
# scriptFrom: https://cdn.jsdelivr.net/npm/live2d-widget@3.x/lib/L2Dwidget.min.js # 你的自定义 url
tagMode: false # 标签模式, 是否仅替换 live2d tag标签而非插入到所有页面中
debug: false # 调试, 是否在控制台输出日志
model:
use: live2d-widget-model-wanko # npm-module package name
# use: wanko # 博客根目录/live2d_models/ 下的目录名
# use: ./wives/wanko # 相对于博客根目录的路径
# use: https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json # 你的自定义 url
display: # 模型展示的位置设置
position: right # 方位
width: 150 # 宽度
height: 300 # 高度
mobile:
show: true # 在移动设备上是否开启live2d

Node环境重新配置

问题描述

在为博客安装新插件时发现由于之前对电脑进行垃圾清理,导致一些环境配置丢失,所以打算重新配置一下。

解决方案

首先去下载 Node.js 的长期支持版本 LTS,这里不再过多做讲解该步骤。下载安装之后在终端里面输入:

node -v

查看安装成功的版本号信息。 之后配置 cnpm 即可:

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

Windows移植博客的若干问题

之前一直是在用 MacOS 作为博客的源平台,然后换了主机之后博客移植这件事一直搁置(其实也有已经搭建了 Qexo 可以在云平台写作的原因)。这一章节总结一下移植过程中出现的问题。

问题描述

首先是 hexo 命令不可用:

PS D:\SOFTWARE\Dev\GitRepo\HEXO-BLOG> hexo -v
hexo : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ hexo -v
+ ~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS D:\SOFTWARE\Dev\GitRepo\HEXO-BLOG> hexo clean
hexo : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ hexo clean
+ ~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

解决方案

这个问题之前从来没有在 Mac 上遇到过,网上查了一下:

设置->隐私和安全性->开发者选项->允许本地PowerShell脚本在为签名的情况下运行

git 密钥过期无法上传

问题描述

很久没有用 mac 写博客了,更新博文后使用 git 上传时出现问题:

> git push
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /Users/apple/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/apple/.ssh/known_hosts:1
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

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

解决方案

这个问题根据报错看起来是密钥过期没办法连到服务器上导致的。

我参考了 ssh远程连接主机报错:Someone could be eavesdropping on you right now (man-in-the-middle attack)! 的解决方案,直接删除本地的主机信息,再次连接时(等于第一次连接)会重新生成远程主机信息:

> rm -rf ~/.ssh/known_hosts

之后就一切正常了。