一、样式缺失的问题

hexo g生成站点文件的时候,经常会出现样式丢失的问题,当你去查看css目录下的文件,可能会发现生成的文件为0kb,空内容,可参考以下解决方式:

打开根目录的配置文件_config.yml

  1. 把 15 行的 url 改成htpps开头的仓库名,比如: https://github.com/xxxx/xxx.github.io.git
  2. 把 16 行的 root 改成 /myBlog.github.io/ 即 /你的项目仓库名/
  3. 然后重新部署 hexo g && hexo d

要注意的是,如果你的站点不是托管在 github 等页面服务上,而是复制到自己的服务器上,请把步骤 2 的 root 改为 /

二、升级最新的 hexo 版本后报 Cannot read property ‘groupBy’ of undefined

由于最新的版本移除内部的 lodash 依赖,所有使用了 lodash 函数的情况下可能会报类似的错误,可参考以下解决方式:

  1. 在 hexo 文件目录下安装 loadsh npm install lodash
  2. 进入 scripts 目录(不存在则创建),新建一个 js 文件(名称无所谓),写入如下内容:
1
2
3
4
5
const _ = require('lodash');

hexo.extend.filter.register('template_locals', locals => {
locals._ = _;
});

本方式参考 github Issues

三、node14 和旧版 hexo 不兼容问题

1
2
3
4
5
6
7
(node:3908) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3908) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:3908) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:3908) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:3908) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:3908) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

解决方式:使用npm-check把所有的 npm 依赖更新为最新版本,hexo 新版已经对兼容问题做了处理。