Hexo Maupassant 主题升级重装记录
Maupassant 好像一直在更新,这次重装,算是跟上了节奏。
(本篇算是写给自己的备忘)
node 降级
遇到了各种各样的报错,最后发现是因为 node 版本过高。遂重新安装 node,降至 12,官网下载 .msi 文件安装包,在卸载高版本 node 后安装即可,node -v 检查版本号。
删除 packege-lock.json
在博客的目录下删除 packege-lock.json 文件,解决 npm WARN old lockfile 报错。
hexo 命令不识别
在博客的目录下,package.json 文件内增加:
1  | "hexo": {  | 
解决 Usage: hexo <command> 报错。
pug 和 sass 插件安装问题
- node-sass 安装,切换国内镜像
 
1  | npm install -g mirror-config-china --registry=http://registry.npm.taobao.org  | 
- 全局模式下安装,node-sass - npm,Node 12 对应安装 4.12+ 版本,安装特定版本命令: 
npm install node-sass@4.12.1 --save-dev 
报错信息:
1  | err: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)  | 
全局模式下安装两个渲染器
1
2npm install hexo-renderer-pug --save
npm install hexo-renderer-sass --savehexo -g试着生成文件,按照报错安装更新缺失的插件,调整,直到不再报错为止
模板配置
- 直接对应之前的 
_config.yml修改的,可以直接把 Waline 配置进去(一般有Vercel内有3个链接,验证一下哪个地址对应评论的输入框,再填写); - 下划线,参考之前的记录即可;
 - Clustrmap 代码配置,参考之前的记录即可,Size 自定义配置先改一个数字,最后在生成的代码内修改为 1px;
 - 中英对照,对着之前的模板配置修改。
 
细节修改
思源宋体增加,head.pug 增加:
1
2
3
4
5
6
7
8
9script.
(function(d) {
var config = {
kitId: 'XXXXXX',
scriptTimeout: 3000,
async: true
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);Adobe 和 Google Fonts 都有,这次仍然沿用了 Adobe 的,不过代码都有更新。
Hypothesis 配置,head.pug 增加:
1
2
3script(type="application/json", class="js-hypothesis-config").
{"showHighlights": false}
script(async, src="https://hypothes.is/embed.js")
部分插件要另行安装
hexo-wordcounthexo-generator-archivehexo-generator-categoryhexo-generator-tag
对照报错逐个安装的,记得要在 Hexo 根目录的 _config.yml 内增加:
1  | # Archives  | 
字体
涉及 .pure-g 和 body 等项下,尤其 .pure-g:
1  | font-family: "source-han-serif-sc", serif, Helvetica, "Helvetica Neue", "Segoe UI", "Hiragino Sans GB", "Source Han Sans CN", "Microsoft YaHei", "STHeiti", "WenQuanYi Micro Hei" !important;  | 
其他可再看效果逐项调整。
其他更新
可右键“检查”,在浏览器修改,查验展示效果,再去改 css 文件。
- header 字体、字号
 - widget 字体、字号
 - post-title 字体、字号
 - post-content 字体
 - post-archive 字体
 - img 文件夹下的二维码
 - 根据 post.pug 修改 page.pug,删除 
page.categories.length部分和include _partial/tag.pug部分 - search.pug 内 self-search,默认填写部分 
placeholder='Local Search' - hypothesis 下划线改色 
f1f1f0或ebebeb 
统计工具增加
Counter.dev
1  | script(src="https://cdn.counter.dev/script.js", data-id="1dc6d9e4-5ed2-4b9e-bbcd-371314b176fd", data-utcoffset="8")  | 
涉及工具
- Jade (Pug) to HTML
 - html2pug - convert your html code to pug
 - Embedding Hypothesis in Websites and Platforms : Hypothesis
 - node-sass - npm
 
参考文章
- hexo 生成的 html 文件为空的问题 - Alan Lee
 - node.js - npm WARN old lockfile The package-lock.json file was created with an old version of npm - Stack Overflow
 - hexo server not working · Issue #1442 · hexojs/hexo · GitHub
 
CHANGELOG
- 20220226 Arlmy 创建、发布
 - 20230424 Arlmy 增加 counter.dev 统计
 
本文标题:Hexo Maupassant 主题升级重装记录
文章作者:arlmy
发布时间:2022-02-26
最后更新:2023-04-24
原始链接:https://z.arlmy.me/posts/hexo/Hexo_UpdateAndRenew/
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
分享