今天升级了主题和本地 hugo 版本,推到 git 仓库后,不出所料 vercel 编译出问题:
Error: add site dependencies: load resources: loading templates: "/vercel/workpath0/themes/meme/layouts/partials/third-party/lunr-search.html:8:1": parse failed: template: partials/third-party/lunr-search.html:8: function "warnf" not defined
解决办法也很简单,hugo 项目的根目录添加 vercel.json
文件,添加以下内容:
{
"build": {
"env": {
"HUGO_VERSION": "0.79.0"
}
}
}
更新这个文件后,vercel 恢复正常:
参考: