雨果数据模板:在哪里创建文件以及将其放入什么?
我有一个雨果SSG网站。
我的json文件保存在:/data/source.json
我创建一个模板文件:/layouts/test.html
具有此内容的内容:
<!-- Data is in /data/source.json -->
{{ range .Site.Data.source }}
{{ range .names }}
<!-- person_name -->
<p>{{ .identifier.person_name }}</p>
{{ end }}
{{ end }}
我该如何渲染。 HTML内容到网站?
雨果文档在这里制作.html文件后我没有解释我需要做什么。
I have a Hugo SSG website.
My JSON file is saved in: /data/source.json
I created a template file: /layouts/test.html
that has this content:
<!-- Data is in /data/source.json -->
{{ range .Site.Data.source }}
{{ range .names }}
<!-- person_name -->
<p>{{ .identifier.person_name }}</p>
{{ end }}
{{ end }}
How do I render this .html content to the website?
The Hugo documentation here doesn't explain what I need to do after making the .html file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您只需要一个
范围
操作。您没有在多个来源上范围。JSON文件,对吗?假设您有一个文件
data/source.json
这样:那么应该可以渲染这样的名称:
将其添加到
themes/{theme {themem {themem {theme布局
将使用该模板在页面上渲染。It looks like you have two
range
operations when you need only one. You are not ranging over multiple source.json files, correct?Assuming you have a file
data/source.json
like this:Then it should be possible to render those names like this:
Add that to a layout in your
themes/{theme-name}/layouts
and it will render on the pages using that template.