HUGO
Menu
GitHub 87548 stars Mastodon

Hugo Param 短代码

使用 param 短代码将参数从 front matter 或站点配置插入到你的内容中。

要覆盖 Hugo 内置的 param 短代码,请将 源代码 复制到 layouts/_shortcodes 目录中同名文件中。

param 短代码渲染来自 front matter 的参数,回退到同名的站点参数。如果参数不存在,短代码会抛出错误。

content/example.md
---
title: 示例
date: 2025-01-15T23:29:46-08:00
params:
  color: red
  size: medium
---

我们找到了一件 {{% param "color" %}} 衬衫。

Hugo 渲染为:

<p>我们找到了一件红色衬衫。</p>

通过 链接 标识符 来访问嵌套值:

{{% param my.nested.param %}}

Last updated: January 1, 0001
Improve this page