hugo v0.152.2 版本更新介绍
发布日期: 2025-10-24
版本号: v0.152.2
在 Hugo v0.152.0 中,我们收紧了模块挂载的源验证。此前已明确:项目挂载可使用绝对路径,而模块与主题仅限相对路径。v0.152.0 进一步限定模块/主题挂载必须为本地路径,导致以下配置失效:
toml [[module.mounts]] source = '../../node_modules/bootstrap' target = 'assets/vendor/bootstrap'这主要出于安全考虑,且该模式通常不符合项目使用主题/模块文件的常规逻辑,移植性较差。但示例中的用法确实存在合理场景,因此我们新增了更便携的支持方式。现在该配置将恢复与 v0.152.0 之前相同的行为,同时未来推荐写法为:toml [[module.mounts]] source = 'node_modules/bootstrap' target = 'assets/vendor/bootstrap'我们将node_modules作为特殊情况处理:对于主题/模块,首先检查挂载源是否存在于本地,若不存在则尝试相对于项目根目录解析。 ## 变更内容 * 依赖更新:github.com/tdewolff/minify 从 v2.24.4 升级至 v2.24.5(1c8c21e45,由 @jmooring 提交,关联 #14086) * hugofs:将node_modules设为特殊挂载情况(809ebe01f,由 @bep 提交,关联 #14089) * GitHub:修复过期 PR 提示信息中的拼写错误(08a0679a8,由 @jordelver 提交)
更新内容 (中文)
在v0.152.0版本中,我们收紧了文件挂载的源验证。我们一直强调:项目挂载可以使用绝对文件/目录名称进行挂载,而模块/主题则限制为相对路径。在v0.152.0中,我们将模块/主题挂载限定为本地路径,这导致以下错误报告中描述的配置失效:
[[module.mounts]]
source = '../../node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
这一限制部分出于安全考虑。但上述构建方式通常非常罕见(项目应使用主题/模块中的文件,而非反向操作),且可移植性较差。不过上述示例展示了一个有效的例外情况,我们现在已为其提供了可移植的支持方案。上述示例现在可以像v0.152.0之前一样正常工作,但今后您也可以采用如下写法:
[[module.mounts]]
source = 'node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
我们现在将node_modules作为特殊情况处理:对于主题/模块,系统会先检查挂载源是否存在本地路径,若不存在则尝试相对于项目根目录解析。
变更内容
- 依赖项:更新 github.com/tdewolff/minify v2.24.4 => v2.24.5 1c8c21e45 @jmooring #14086
- hugofs:将 node_modules 设为“特殊情况”挂载 809ebe01f @bep #14089
- github:修复过期PR消息中的拼写错误 08a0679a8 @jordelver
更新内容 (原始)
In v0.152.0 we tightened the source validation for file mounts. We always said that project mounts can mount with absolute file/directorynames, modules/themes are restricted to relative. In v0.152.0 we narrowed module/themes mounts to be local, which made the setup in the bug report listed below fail:
[[module.mounts]]
source = '../../node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
One part of this is security. But the construct above is usually very odd (the project uses files in a theme/module, not the other way around) and not very portable. But the example above demonstrates a valid exception, that we now have added support for in a portable way. The above example now works as it did before v0.152.0, but going forward you can also write:
[[module.mounts]]
source = 'node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
We now have the node_modules as a special case: For themes/modules we first check if the mounted source exists locally, if not we try relative to the project root.
What’s Changed
- deps: Update github.com/tdewolff/minify v2.24.4 => v2.24.5 1c8c21e45 @jmooring #14086
- hugofs: Make node_modules a “special case” mount 809ebe01f @bep #14089
- github: Fix typo in stale PR message 08a0679a8 @jordelver
下载链接
- hugo_0.152.2_checksums.txt
- hugo_0.152.2_darwin-universal.tar.gz
- hugo_0.152.2_dragonfly-amd64.tar.gz
- hugo_0.152.2_freebsd-amd64.tar.gz
- hugo_0.152.2_Linux-64bit.tar.gz
- hugo_0.152.2_linux-amd64.deb
- hugo_0.152.2_linux-amd64.tar.gz
- hugo_0.152.2_linux-arm.tar.gz
- hugo_0.152.2_linux-arm64.deb
- hugo_0.152.2_linux-arm64.tar.gz
- hugo_0.152.2_netbsd-amd64.tar.gz
- hugo_0.152.2_openbsd-amd64.tar.gz
- hugo_0.152.2_solaris-amd64.tar.gz
- hugo_0.152.2_windows-amd64.zip
- hugo_0.152.2_windows-arm64.zip
- hugo_extended_0.152.2_darwin-universal.tar.gz
- hugo_extended_0.152.2_Linux-64bit.tar.gz
- hugo_extended_0.152.2_linux-amd64.deb
- hugo_extended_0.152.2_linux-amd64.tar.gz
- hugo_extended_0.152.2_linux-arm64.deb
- hugo_extended_0.152.2_linux-arm64.tar.gz
- hugo_extended_0.152.2_windows-amd64.zip
- hugo_extended_withdeploy_0.152.2_darwin-universal.tar.gz
- hugo_extended_withdeploy_0.152.2_Linux-64bit.tar.gz
- hugo_extended_withdeploy_0.152.2_linux-amd64.deb
- hugo_extended_withdeploy_0.152.2_linux-amd64.tar.gz
- hugo_extended_withdeploy_0.152.2_linux-arm64.deb
- hugo_extended_withdeploy_0.152.2_linux-arm64.tar.gz
- hugo_extended_withdeploy_0.152.2_windows-amd64.zip