在 Hugo v0.55 的 YAML 文件中获取 Hugo 的版本号

Get Hugo's version number in YAML files in Hugo v0.55

问题

在 Hugo v0.55 下 i18n/*.yaml 中获取 Hugo 版本号的正确方法是什么?

背景

我正在使用 Hugo with the theme Beautiful Hugo,其中包含以下自 v0.55 以来已弃用的语法:

  1. .URL
  2. .Hugo
  3. .RSSLink

#2 在语言环境文件 i18n/*yaml 中用于获取 Hugo 的版本号 {{ .Hugo.Version }},但这是 已弃用

因此,当 运行 hugo server.

时,我的终端显示了与此类似的消息
Building sites … WARN 2019/04/09 10:14:55 Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.
WARN 2019/04/09 10:14:55 Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
WARN 2019/04/09 10:14:55 Page's .RSSLink is deprecated and will be removed in a future release. Use the Output Format's link, e.g. something like:
{{ with .OutputFormats.Get "RSS" }}{{ . RelPermalink }}{{ end }}.

来源:https://gist.github.com/chris-short/78582dc32f877d65eb388f832d2c1dfa

目标

如何抑制警告 #2 .Hugo? (我已经完成了#1 和#3)。

尝试

@peaceiris 在 Qiita 上建议 changing {{ .Hugo.Generator }} to {{ hugo.Generator }}

图片来源:linked blog post

我将其应用于语言环境 i18n/*.yaml。即我在那些 YAML 文件中用 {{ hugo.Version }} 替换了 {{ .Hugo.Version }}。但是,我收到 function "hugo" not defined 错误。我在Go-HTML模板文件中测试了{{ hugo.Version }},没问题。

Error: "/home/vin100/beautifulhugo/i18n/zh-TW.yaml:1:1": failed to load translations: unable to parse translation #14 because template: 由 <a href="http://gohugo.io">Hugo v{{ hugo.Version }}</a> 提供 &nbsp;&bull;&nbsp; 主題 <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a> 移植自 <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a>:1: function "hugo" not defined
map[id:poweredBy translation:由 <a href="http://gohugo.io">Hugo v{{ hugo.Version }}</a> 提供 &nbsp;&bull;&nbsp; 主題 <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a> 移植自 <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a>]

感谢 Hugo Discourse 上的@bep,我找到了解决方案!只需使用 {{ .Site.Hugo.Version }}.

参考:@bep's answer on Hugo Discourse