发布日期: 2025-04-25
版本号: v0.147.0

本次Hugo更新引入了aligny选项,配合alignx可方便实现文字在图片上的双向居中对齐。更重要的是优化了Hugo应用默认配置的顺序逻辑,解决了之前从模块/主题合并配置时的困难,现在可以通过_merge = "deep"轻松实现多站点共享通用配置。此外修复了代码块渲染优先级、Vimeo/YouTube短代码选项及配置合并等问题,并更新了相关依赖项。

更新内容 (中文)

本次发布引入了新的 aligny 选项(感谢 @pranshugaba 的实现),用于 images.Text,结合 alignx 可以轻松实现例如将文本在图像上双向居中等效果。但本次发布提前而至的主要原因,在于改进/修复了 Hugo 将默认配置应用于某些键值的顺序。这源自我们在重写配置处理逻辑前采用的方式,它使得模块/主题的配置合并到根配置变得比实际需要更困难、更不灵活。本人 @bep 在研究此问题时,受到该论坛讨论的启发。多个站点共享通用配置非常实用。通过本次发布,您只需通过如下配置即可实现发帖者所需的功能:

baseURL = "http://example.org"
title = "My Hugo Site"

# ... 导入任意主题/模块。

# 这将合并从导入模块获取的所有配置。
_merge = "deep"

详见文档了解详情。

错误修复

  • tpl:修复以确保内部代码块渲染始终优先于 render-codeblock-foo.html 及类似模板 07983e04e @bep #13651
  • tpl/tplimpl:修复 Vimeo 和 YouTube 短代码中的 allowFullScreen 选项 5c491409d @jmooring #13650
  • config:修复当左侧键值不存在时 _merge 出现的问题 179aea11a @bep #13643 #13646
  • all:修复拼写错误 6a0e04241 @coliff

功能改进

  • create/skeletons:调整主题骨架中的模板名称 75b219db8 @jmooring
  • tpl:移除部分未执行到的代码分支 ad4f63c92 @bep
  • images:为 images.Text 的 aligny 功能添加测试用例 53202314a @bep #13414
  • images:为 images.Text 添加垂直对齐选项 2fce0bac0 @pranshugaba

依赖更新

  • build(deps):将 github.com/evanw/esbuild 从 0.25.2 升级至 0.25.3 1bd7ac7ed @dependabot[bot]
  • build(deps):将 github.com/alecthomas/chroma/v2 从 2.16.0 升级至 2.17.0 41cb880f9 @dependabot[bot]

更新内容 (原始)

This release comes with a new aligny option (shoutout to @pranshugaba for the implementation) for images.Text that, in combination with alignx makes it simple to e.g. center the text on top of image in both axis. But the main reason this release comes now and not later, is the improvements/fixes to the order Hugo applies the default configuration to some keys. This is inherited from how we did this before we rewrote the configuration handling, and it made the merging of configuration from modules/themes into the config root harder and less flexible than it had to be. Me, @bep, looking into this, was triggered by this forum topic. Having many sites share a common configuration is very useful. With this release, you can simply get what the thread starter asks for by doing something à la:

baseURL = "http://example.org"
title = "My Hugo Site"

# ... import any themes/modules.

# This will merge in all config imported from imported modules. 
_merge = "deep"

See the documentation for details.

Bug fixes

  • tpl: Fix it so we always prefer internal codeblock rendering over render-codeblock-foo.html and similar 07983e04e @bep #13651
  • tpl/tplimpl: Fix allowFullScreen option in Vimeo and YouTube shortcodes 5c491409d @jmooring #13650
  • config: Fix _merge issue when key doesn’t exist on the left side 179aea11a @bep #13643 #13646
  • all: Fix typos 6a0e04241 @coliff

Improvements

  • create/skeletons: Adjust template names in theme skeleton 75b219db8 @jmooring
  • tpl: Remove some unreached code branches ad4f63c92 @bep
  • images: Add some test cases for aligny on images.Text 53202314a @bep #13414
  • images: Add option for vertical alignment to images.Text 2fce0bac0 @pranshugaba

Dependency Updates

  • build(deps): bump github.com/evanw/esbuild from 0.25.2 to 0.25.3 1bd7ac7ed @dependabot[bot]
  • build(deps): bump github.com/alecthomas/chroma/v2 from 2.16.0 to 2.17.0 41cb880f9 @dependabot[bot]

下载链接