发布日期: 2025-04-10
版本号: v0.146.0

Hugo发布了v0.146.1版本,主要修复了v0.146.0引入的回归问题。该版本核心更新是重构了模板系统,使其更简洁高效,同时保持了向后兼容性。新增了templates.Current函数用于调试,以及time.In函数处理时区转换。此外还修复了视频短代码全屏选项问题,改进了模板缓存和主题创建流程,并更新了多个依赖库。建议用户在升级前测试网站兼容性。文档更新仍在进行中。

更新内容 (中文)

[!NOTE] 已发布 v0.146.1 错误修复版本,修复了此版本引入的回归问题。

此版本最重要的更新是全面重构的模板系统——更简洁且更强大。我们正在完善相关文档,更多细节请参阅 此议题。我们已尽最大努力保证向后兼容性,但仍建议在正式使用前测试您的网站。此版本还包括完整的依赖项更新及若干实用的新模板函数:

  • templates.Current:获取当前执行模板及其调用栈信息,对调试极有帮助
  • time.In:将指定日期/时间转换为目标IANA时区表示

错误修复

  • tpl/tplimpl: 修复vimeo和youtube短代码的全屏选项 6f14dbe24 @jmooring #13531

功能改进

  • tpl: 对/layouts/_markup目录下的非钩子模板发出警告并跳过 383dd82f9 @bep #13577
  • tpl: 添加局部模板查找缓存 208a0de6c @bep #13571
  • tpl: 新增templates.Current函数 d4c6dd16b @bep #13571
  • commands/new: 优化主题创建流程 24ac6a9de @jmooring #13489 #13544
  • tpl/tplimpl: 更新嵌入式分页模板 1e0084248 @jmooring
  • 重构并简化Hugo模板系统 83cfdd78c @bep #13541 #13545 #13515 #7964 #13365 #12988 #4891
  • config: 尽可能使用非全局日志记录器处理弃用警告 812ea0b32 @bep
  • tpl/time: 新增time.In函数 07cbe5701 @jmooring #13548
  • resources: 添加静默依赖弃用警告的选项 c15ebce2f @jmooring #13530
  • common/hreflect: 用sync.Map替代map/RWMutex方法缓存 8d2379bcb @bep
  • common/hexec: 移除github.com/cli/safeexec依赖 a6bd67793 @jmooring #13516
  • parser/metadecoder: 优化非map类型XML根节点的错误提示 f34cdc382 @thevilledev
  • identity: 使用clear清空finder的seen映射 52561d561 @bep
  • cache: 为轮询配置应用httpcache默认值 d28c84a87 @khayyamsaleem #13471
  • tpl/tplimpl: 为Vimeo短代码添加loading属性 b9add1c70 @jmooring #13445
  • commands: 为gen chromastyles添加–omitEmpty标志 93df17661 @jmooring #13475
  • tpl: 为robots.txt模板添加末尾换行符 eebea9ec4 @willfaught
  • commands: 在Windows跳过不稳定的测试 3f2e1c08e @bep #13465
  • resources/image: 将loong64标记为使用FMA指令集的架构 3a11d22da @hannesbraun

依赖更新

  • build(deps): 升级github.com/fsnotify/fsnotify从1.8.0到1.9.0 18d2d2f98 @dependabot[bot]
  • build(deps): 升级golang.org/x/tools从0.31.0到0.32.0 cd3e3499b @dependabot[bot]
  • build(deps): 升级github.com/evanw/esbuild从0.25.1到0.25.2 8cd799aac @dependabot[bot]
  • build(deps): 升级golang.org/x/image从0.25.0到0.26.0 af0602c34 @dependabot[bot]
  • build(deps): 升级github.com/pelletier/go-toml/v2从2.2.3到2.2.4 650fe6cd0 @dependabot[bot]
  • build(deps): 升级github.com/alecthomas/chroma/v2从2.15.0到2.16.0 d63491beb @dependabot[bot]
  • build(deps): 升级golang.org/x/net从0.37.0到0.39.0 e6e18e912 @dependabot[bot]
  • build(deps): 升级github.com/bep/imagemeta从0.10.0到0.11.0 43af3bc07 @dependabot[bot]
  • deps: 升级github.com/gohugoio/hugo-goldmark-extensions/passthrough从v0.3.0到v0.3.1 10b55439a @jmooring
  • build(deps): 升级golang.org/x/tools从0.30.0到0.31.0 26d986fc0 @dependabot[bot]
  • build(deps): 升级github.com/getkin/kin-openapi从0.129.0到0.131.0 ebc069365 @dependabot[bot]
  • build(deps): 升级github.com/spf13/afero从1.11.0到1.14.0 7ca6bb06b @dependabot[bot]
  • build(deps): 升级github.com/bep/imagemeta从0.9.0到0.10.0 bddd2f900 @dependabot[bot]
  • build(deps): 升级github.com/golang-jwt/jwt/v5从5.2.1到5.2.2 1c691358f @dependabot[bot]
  • build(deps): 升级github.com/evanw/esbuild从0.24.2到0.25.1 17db4edb0 @dependabot[bot]
  • build(deps): 升级github.com/bep/godartsass/v2从2.4.0到2.4.1 3968f9158 @dependabot[bot]
  • build(deps): 升级golang.org/x/net从0.35.0到0.37.0 e9bd2373a @dependabot[bot]
  • build(deps): 升级github.com/bep/godartsass/v2从2.3.2到2.4.0 f4f21f5ea @dependabot[bot]
  • build(deps): 升级golang.org/x/image从0.24.0到0.25.0 61c39ae63 @dependabot[bot]
  • deps: 升级golang.org/x/mod从v0.23.0到v0.24.0 2037137fb @bep #13484
  • build(deps): 升级github.com/bep/overlayfs从0.9.2到0.10.0 d78d4cf16 @dependabot[bot]
  • build(deps): 升级github.com/bep/lazycache从0.7.0到0.8.0 f9aae1581 @dependabot[bot]
  • build(deps): 升级github.com/bep/imagemeta从0.8.4到0.9.0 b0686712b @dependabot[bot]
  • build(deps): 升级github.com/bep/simplecobra从0.5.0到0.6.0 93d9c0533 @dependabot[bot]

文档更新

  • commands/gen: 将命令页面的URL设置为/docs/reference/commands/ a98ec3bd0 @jmooring

更新内容 (原始)

[!NOTE] There’s a v0.146.1 bug fix release that fixes a regression introduced in this release.

The big new thing in this release is a fully refreshed template system – simpler and much better. We’re working on the updated documentation for this, but see this issue for some more information. We have gone to great lengths to make this as backwards compatible as possible, but make sure you test your site before going live with this new version. This version also comes with a full dependency refresh and some useful new template funcs:

  • templates.Current: Info about the current executing template and its call stack. Very useful for debugging.
  • time.In: Returns the given date/time as represented in the specified IANA time zone.

Bug fixes

  • tpl/tplimpl: Fix full screen option in vimeo and youtube shortcodes 6f14dbe24 @jmooring #13531

Improvements

  • tpl: Warn and skip non-hook templates inside /layouts/_markup 383dd82f9 @bep #13577
  • tpl: Add a partial lookup cache 208a0de6c @bep #13571
  • tpl: Add templates.Current d4c6dd16b @bep #13571
  • commands/new: Improve theme creation 24ac6a9de @jmooring #13489 #13544
  • tpl/tplimpl: Update embedded pagination template 1e0084248 @jmooring
  • Reimplement and simplify Hugo’s template system 83cfdd78c @bep #13541 #13545 #13515 #7964 #13365 #12988 #4891
  • config: Use the non-global logger for deprecations when possible 812ea0b32 @bep
  • tpl/time: Add time.In function 07cbe5701 @jmooring #13548
  • resources: Add option to silence dependency deprecation warnings c15ebce2f @jmooring #13530
  • common/hreflect: Replace the map/RWMutex method cache with sync.Map 8d2379bcb @bep
  • common/hexec: Remove github.com/cli/safeexec a6bd67793 @jmooring #13516
  • parser/metadecoder: Improve errors for non-map XML root values f34cdc382 @thevilledev
  • identity: Use clear to clear the finder seen map 52561d561 @bep
  • cache: Apply httpcache defaults for polling config d28c84a87 @khayyamsaleem #13471
  • tpl/tplimpl: Add loading attribute to Vimeo shortcode b9add1c70 @jmooring #13445
  • commands: Add –omitEmpty flag to gen chromastyles 93df17661 @jmooring #13475
  • tpl: Add trailing newline to robots.txt template eebea9ec4 @willfaught
  • commands: Skip flaky test on Windows 3f2e1c08e @bep #13465
  • resources/image: Mark loong64 as FMA-using architecture 3a11d22da @hannesbraun

Dependency Updates

  • build(deps): bump github.com/fsnotify/fsnotify from 1.8.0 to 1.9.0 18d2d2f98 @dependabot[bot]
  • build(deps): bump golang.org/x/tools from 0.31.0 to 0.32.0 cd3e3499b @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.25.1 to 0.25.2 8cd799aac @dependabot[bot]
  • build(deps): bump golang.org/x/image from 0.25.0 to 0.26.0 af0602c34 @dependabot[bot]
  • build(deps): bump github.com/pelletier/go-toml/v2 from 2.2.3 to 2.2.4 650fe6cd0 @dependabot[bot]
  • build(deps): bump github.com/alecthomas/chroma/v2 from 2.15.0 to 2.16.0 d63491beb @dependabot[bot]
  • build(deps): bump golang.org/x/net from 0.37.0 to 0.39.0 e6e18e912 @dependabot[bot]
  • build(deps): bump github.com/bep/imagemeta from 0.10.0 to 0.11.0 43af3bc07 @dependabot[bot]
  • deps: Upgrade github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.3.0 => v0.3.1 10b55439a @jmooring
  • build(deps): bump golang.org/x/tools from 0.30.0 to 0.31.0 26d986fc0 @dependabot[bot]
  • build(deps): bump github.com/getkin/kin-openapi from 0.129.0 to 0.131.0 ebc069365 @dependabot[bot]
  • build(deps): bump github.com/spf13/afero from 1.11.0 to 1.14.0 7ca6bb06b @dependabot[bot]
  • build(deps): bump github.com/bep/imagemeta from 0.9.0 to 0.10.0 bddd2f900 @dependabot[bot]
  • build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 1c691358f @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.24.2 to 0.25.1 17db4edb0 @dependabot[bot]
  • build(deps): bump github.com/bep/godartsass/v2 from 2.4.0 to 2.4.1 3968f9158 @dependabot[bot]
  • build(deps): bump golang.org/x/net from 0.35.0 to 0.37.0 e9bd2373a @dependabot[bot]
  • build(deps): bump github.com/bep/godartsass/v2 from 2.3.2 to 2.4.0 f4f21f5ea @dependabot[bot]
  • build(deps): bump golang.org/x/image from 0.24.0 to 0.25.0 61c39ae63 @dependabot[bot]
  • deps: Upgrade golang.org/x/mod v0.23.0 => v0.24.0 2037137fb @bep #13484
  • build(deps): bump github.com/bep/overlayfs from 0.9.2 to 0.10.0 d78d4cf16 @dependabot[bot]
  • build(deps): bump github.com/bep/lazycache from 0.7.0 to 0.8.0 f9aae1581 @dependabot[bot]
  • build(deps): bump github.com/bep/imagemeta from 0.8.4 to 0.9.0 b0686712b @dependabot[bot]
  • build(deps): bump github.com/bep/simplecobra from 0.5.0 to 0.6.0 93d9c0533 @dependabot[bot]

Documentation

  • commands/gen: Set url in command pages to /docs/reference/commands/ a98ec3bd0 @jmooring

下载链接