跳过正文

GitInfo

Hugo .GitInfo 的替代方案
·569 字·2 分钟
代码 Githash Hugo GitInfo Git
Hugo 的 .GitInfo 变量因设计限制无法正确显示 content 目录的 Commit hash,尤其在浅克隆时更易失效。通过自定义脚本动态替换模板中的占位字符串,可绕过该限制实时显示最新 Git hash。该方法需在构建前执行脚本更新模板,虽非官方方案但能有效解决问题。