安装katex渲染器后,文章图片路径解析从绝对路径变为文章相对路径
Author: vistar-terryCreated Jun 7, 2026Updated Jun 7, 2026
Labels:bug: bug
请确认
- [ √ 1.9.9 ] 是当前最新的 Release 版本
- [ √ ] 本地
hexo clean && hexo s,并且清除浏览器缓存,仍可复现 - [ √ ] 已经排除是其他 Hexo 插件影响
Bug 描述
使用katex解析公式,安装相应渲染器后,文章图片路径解析从绝对路径变为文章相对路径,例如: 安装前:http://localhost:4000/img/article/202008/20200330183554388.jpg 安装后:http://localhost:4000/2020/08/01/article_title/img/article/202008/20200330183554388.jpg 导致文章中的图片无法显示,浏览器: Chrome 148.0.7778.178 (Official Build) (64-bit)
版本号:
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server"
},
"hexo": {
"version": "7.3.0"
},
"dependencies": {
"@traptitech/markdown-it-katex": "^3.6.0",
"hexo": "^7.0.0",
"hexo-deployer-git": "^4.0.0",
"hexo-generator-archive": "^2.0.0",
"hexo-generator-category": "^2.0.0",
"hexo-generator-index": "^3.0.0",
"hexo-generator-tag": "^2.0.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-markdown-it": "^6.1.0",
"hexo-renderer-stylus": "^3.0.0",
"hexo-server": "^3.0.0",
"hexo-theme-fluid": "^1.9.9",
"hexo-theme-landscape": "^1.0.0"
}
}katex配置: _config.yml
markdown:
plugins:
- "@traptitech/markdown-it-katex"
render:
html: true
linkify: true
katex:
css: https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css_config.fluid.yml
math:
enable: true
specific: true
engine: katex复现步骤
该 Bug 复现步骤如下:
- 开始使用 mathjax
- 按照 https://hexo.fluid-dev.com/docs/guide/#latex-%E6%95%B0%E5%AD%A6%E5%85%AC%E5%BC%8F 的步骤切换到 katex
- 然后依次执行 hexo clean -> hexo g -> hexo s
- 打开文章页,公式可正确渲染,但图片无法显示,路径如上所述
复现的页面地址: https://www.vistary.cn/2020/08/01/PointNet++%20%E6%96%87%E7%8C%AE%E7%BF%BB%E8%AF%91%E9%98%85%E8%AF%BB%E5%8F%8A%E6%8B%93%E5%B1%95%E9%98%85%E8%AF%BB/ 或 https://vistar-terry.github.io/2020/08/01/PointNet++%20%E6%96%87%E7%8C%AE%E7%BF%BB%E8%AF%91%E9%98%85%E8%AF%BB%E5%8F%8A%E6%8B%93%E5%B1%95%E9%98%85%E8%AF%BB/
截图
Source: fluid-dev/hexo-theme-fluid