当数据全部消失,部署hexo全过程与踩坑记录

2021年,我电脑更换了主板,数据全部消失。

于是我开始了重新部署Hexo的征程。

因为时间原因,后续会补上我之前关于电脑修复的文章,首先发表于少数派

安装首先根据我之前的迁移目录下的文章,之后根据skycrown的知乎回答一步一步走。

踩坑

关于我的其他Hexo的问题与优化记录,可配合查看:LeanCloud国内版迁移至国际版

版本过低

本地预览出现错误

Version 9 of Highlight.js has reached EOL and is no longer supported.
Please upgrade or ask whatever dependency you are using to upgrade.
https://github.com/highlightjs/highlight.js/issues/2877
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Nunjucks Error:  [Line 70, Column 6] expected name as lookup value, got .
    =====               Context Dump               =====
    === (line number probably different from source) ===
  65 | <pre class="highlight"><code class="">
  66 | {{
  67 |    paginator({
  68 |    prev_text: '<i class="fa fa-angle-left" aria-label="'+__('accessibility.prev_page')+'"></i>',
  69 |    next_text: '<i class="fa fa-angle-right" aria-label="'+__('accessibility.next_page')+'"></i>',
  70 |    ...
  71 |  })
  72 | 
73 |

网站总访问量修正

74 |

更新了不蒜子的域名,官方解释在这里

75 |

修改busuanzi-counter.swig

===== Context Dump Ends ===== ``` 以及以下错误: ```bash at formatNunjucksError (/Users/yourname/FelixXiongHexo/node_modules/hexo/lib/extend/tag.js:102:13) at /Users/yourname/FelixXiongHexo/node_modules/hexo/lib/extend/tag.js:124:34 at tryCatcher (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/Users/yourname/FelixXiongHexo/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:439:21) ``` npm报错 ```bash npm WARN deprecated core-js@2.6.12: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3. ``` 升级core.js ```bash sudo npm install --save core-js@^3 ``` **检查npm更新** ```bash npm-check ``` 升级旧版本(根据知乎的迁移回答,我安装的hexo居然是3.9版本) ```bash npm install --save hexo@5.4.0 npm install --save hexo-deployer-git@3.0.0 npm install --save hexo-renderer-ejs@1.0.0 npm install --save hexo-renderer-stylus@2.0.1 npm install --save hexo-server@2.0.0 npm install --save hexo-generator-tag@1.0.0 npm install --save hexo-generator-sitemap@2.1.0 npm install --save hexo-wordcount@6.0.1 ``` ### 升级后  本地预览出现: ```json {% extends '_layout.swig' %} {% import '_macro/post.swig' as post_template %} {% import '_macro/sidebar.swig' as sidebar_template %} {% block title %}{{ config.title }}{% if theme.index_with_subtitle and config.subtitle %} - {{config.subtitle }}{% endif %}{% endblock %} {% block page_class %} {% if is_home() %}page-home{% endif -%} {% endblock %} {% block content %} {% for post in page.posts %} {% if post.visible !== 'hide' %} {{ post_template.render(post, true) }} {% endif %} {% endfor %} {% include '_partials/pagination.swig' %} {% endblock %} {% block sidebar %} {{ sidebar_template.render(false) }} {% endblock %}

安装:

npm i hexo-renderer-swig

hexo c清理缓存,hexo g & s 即可

页脚问题

页脚出现“下一页按钮变成代码”的问题后,修改以下代码后仍直接出现代码:

prev_text: '<i class="fa fa-angle-left" aria-label="'+__('accessibility.prev_page')+'"></i>',
next_text: '<i class="fa fa-angle-right" aria-label="'+__('accessibility.next_page')+'"></i>',
mid_size: 1, 
escape: false #增加此行

hexo和themes Next版本升级

How to update core-js to core-js@3 dependency?

 wechat
产品北里,讲述产品和人性、涉及设计、技术和运营的公众号。
你们的赞赏是我更新的动力~