Butterfly 常见问题解答

网页显示代码

问题:页面只显示 extends includes/layout.pug block content #recent-posts.recent-posts include includes/recent-posts.pug 等代码

解决方案:安装必要的渲染器

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

配置友情链接报错

问题:配置友情链接页面时出现 Cannot read property 'length' of undefined 错误

解决方案:检查 link.yml 文件中代码的空格缩进,确保 YAML 格式正确

升级最新版后运行报错

问题:升级后执行 hexo g 报错 TypeError: Cannot read property 'enable' of undefined

解决方案:参照最新版的 _config.yml,对比后将缺失的配置复制到主题配置文件中

wordcount 函数错误

问题:报错 wordcount is not a functiontotalcount is not a function

解决方案:安装 wordcount 插件

1
npm i --save hexo-wordcount

升级 2.0.0 版本后报错

问题:升级到 2.0.0 后出现 Template render error: unexpected end of file

解决方案:2.0.0 版本删除了旧的 gallery,引入了新的 gallery。需要删除或更改旧的 gallery 写法

代码渲染与实际不同

问题:2.1.0 以下版本中代码渲染结果与预期不同

解决方案:安装正确版本的 cheerio

1
npm install cheerio@0.22.0 --save

搜索栏在底部

问题hexo deploy 后搜索栏出现在页面底部

解决方案:生成前先执行 hexo clean

本地正常但上传后出错

问题:本地可以正常运行,但 push 上去后出现缺失或无效

解决方案

  1. 清理浏览器缓存
  2. 确认上传时是否运行了 hexo clean

导航栏仍然是英文

问题:已在 Hexo 配置文件设置了语言,但导航栏仍然是英文

解决方案:在导航配置中自己修改为中文

1
2
3
4
首页: / || fa fa-home
时间轴: /archives/ || fa fa-archive
标签: /tags/ || fa fa-tags
分类: /categories/ || fa fa-folder-open

Cannot read property ‘bind’ of undefined

问题:报错 TypeError: Cannot read property 'bind' of undefinedfull_url_for is not function

解决方案:将 Hexo 升级到 4.0 以上版本

Cannot read property ‘appId’ of undefined

问题:Algolia 搜索配置报错

解决方案:Algolia 插件安装后还需要进行配置,查看插件文档进行配置

顶部出现 Loading

问题:页面顶部显示 Loading 加载动画

解决方案:生成前先执行 hexo clean

点击中文目录报错

问题:点击中文目录时出现错误(主题 3.0.0 以下版本)

解决方案:升级主题到最新版本

Uncaught ReferenceError: regeneratorRuntime is not defined

问题:使用 babel 压缩代码时出现此错误

解决方案:查看 babel/gulp-babel 官方文档获取解决方案

总结

大多数问题都可以通过以下方式解决:

  1. 确保安装了所有必要的依赖和渲染器
  2. 检查配置文件的格式和缩进
  3. 定期执行 hexo clean 清理缓存
  4. 保持 Hexo 和主题版本最新
  5. 查看官方文档和插件文档

如果问题仍未解决,建议在 GitHub 上提交 Issue 或查看相关讨论。