发布日期: 2025-10-21
版本号: v0.152.0

本次更新主要将底层 YAML 库升级至更现代的 github.com/goccy/go-yaml。该升级带来了行为上的细微变化,特别是旧版 YAML 1.1 规范中一些未加引号的字符串(如 yesonnooff 等)会被视为布尔值 truefalse,而新版则将它们视为普通字符串。因此,若配置文件中使用了这些值作为布尔值,则需要进行相应调整。同时,新库新增了对 YAML 锚点与别名的支持,有助于减少配置中的重复内容。

更新内容 (中文)

大型新特性及本次发布的动机在于升级至更现代化的YAML库@goccy的github.com/goccy/go-yaml。通往此处的旅程漫长而曲折。需注意此次升级包含部分细微的破坏性变更,最主要的是旧版YAML 1.1规范中定义的一组字符串在未加引号时会被解析为布尔值truefalse 若您在下方表格中使用任何值作为布尔类型,则需要调整YAML配置。但我认为修正这一非常规行为带来的问题将多于其引发的问题。此新YAML库的重要新特性是支持YAML锚点与别名,这有助于减少配置文件等内容的重复。Hugo的发布构建配置Hugo持续集成发布配置中均提供了相关示例。

取值 旧含义 新含义
yes, Yes, YES, y, Y, on, On, ON true(布尔值) yes, Yes, YES, y, Y, on, On, ON(字符串)
no, No, NO, n, N, off, Off, OFF false(布尔值) no, No, NO, n, N, off, Off, OFF(字符串)

备注

  • 将gopkg.in/yaml替换为github.com/goccy/go-yaml(备注)a3d954846 @bep #8822 #13043 #14053

改进

  • 配置:修改前克隆语言映射条目 a1307700d @bep #14072
  • 暂时跳过不稳定测试 9425b939c @bep #14072
  • 杂项YAML调整 bd50c9c7e @bep #14067
  • hugofs:确保非项目模块挂载为本地路径 a8e0ca925 @bep #14069
  • langs/i18n:改进保留键错误信息 559a029de @jmooring #14061
  • langs:添加使用"保留"国际语言代码的测试用例 5bad0d523 @bep #14061

依赖更新

  • 依赖:升级github.com/gohugoio/go-i18n/v2 184b10ed4 @bep
  • 构建依赖:将github.com/tdewolff/minify/v2从2.24.3升级至2.24.4 9e344bbe4 @dependabot[bot]

构建配置

  • 合并’release-0.151.2’分支 d51adca26 @bep

更新内容 (原始)

The big new thing and the motivation behind this release is the upgrade to a more modern YAML library in @goccy ’s github.com/goccy/go-yaml. It’s been a surprisingly long and winding road to get here. Note that this upgrade comes with some minor breaking changes, most notably that the old YAML 1.1 spec listed a set of strings that, when unquoted, were treated as boolean true or false. So if you’re using any of the values in the table below as booleans, you need to adjust your YAML, but I suspect that fixing this very surprising behavior will fix more issues than it introduces. A big new thing with this new YAML library is the support for YAML anchors and aliases which helps to reduce duplication in e.g. your configuration. There are some examples in Hugo’s release build configuration and in the Hugo’s CI release setup.

Values Old meaning New meaning
yes, Yes, YES, y, Y, on, On, ON true (bool) yes, Yes, YES, y, Y, on, On, ON (string)
no, No, NO, n, N, off, Off, OFF false (bool) no, No, NO, n, N, off, Off, OFF (string)

Note

  • Replace to gopkg.in/yaml with github.com/goccy/go-yaml (note) a3d954846 @bep #8822 #13043 #14053

Improvements

  • config: Clone language map entries before modifying them a1307700d @bep #14072
  • Skip flaky test for now 9425b939c @bep #14072
  • Misc YAML adjustments bd50c9c7e @bep #14067
  • hugofs: Make sure that non-project module mounts are local paths a8e0ca925 @bep #14069
  • langs/i18n: Improve reserved key error message 559a029de @jmooring #14061
  • langs: Add test case using a “reserved” i18n code 5bad0d523 @bep #14061

Dependency Updates

  • deps: Upgrade github.com/gohugoio/go-i18n/v2 184b10ed4 @bep
  • build(deps): bump github.com/tdewolff/minify/v2 from 2.24.3 to 2.24.4 9e344bbe4 @dependabot[bot]

Build Setup

  • Merge branch ‘release-0.151.2’ d51adca26 @bep

下载链接