如何使用 Hugo 定位页面上模板的首次使用?

How to target the first use of a template on a page with Hugo?

我想在使用 Hugo 的页面上首次使用模板时添加一个 ID。

是否有某种方法可以测试在页面上首次使用模板?

例如我的页面有两个邮件列表注册表单,都来自我的 'subscribe.html' 部分。我想将 id="subscribe" 添加到第一个实例,以便我可以使用 link.

来定位它

使用 Scratch 检查并设置标志,请参阅:

https://gohugo.io/extras/scratch/