渲染 Hugo 中特定类别的帖子
我从 Hugo 开始,但没有找到好的定制示例。 我需要渲染名为“视频”的类别中的所有帖子,以在模板“list.html”内的主站点上显示。
如何更改 term.html 模板中的代码以仅处理这个单一类别?任何帮助将不胜感激!
<div class="container">
<article>
<main>
<h1>{{ $.Scratch.Get "Title" }}</h1>
<ul class="terms">
{{ range $key, $value := .Data.Terms }}
<li>
<a href="{{ (print "/" $.Data.Plural "/" $key) | relURL }}">
{{ $key }}
</a>
({{ len $value }})
</li>
{{ end }}
</ul>
</main>
</article>
</div>
I started with Hugo but dont find good examples for customization.
I need to render all posts in a category called e.g. "video" to show on main site within a template "list.html".
How to change the code from term.html template to adress only this single category? Any help would be deeply appreciated!
<div class="container">
<article>
<main>
<h1>{{ $.Scratch.Get "Title" }}</h1>
<ul class="terms">
{{ range $key, $value := .Data.Terms }}
<li>
<a href="{{ (print "/" $.Data.Plural "/" $key) | relURL }}">
{{ $key }}
</a>
({{ len $value }})
</li>
{{ end }}
</ul>
</main>
</article>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我根据主题中可用的 list.html 为名为“cats”的类别开发了以下代码:
如果它位于 list.html 中,则它仅显示此特定类别中的帖子。或者可以将其放入单独的部分模板 cats.html 中
I developed following code for category called "cats" based on list.html available in my theme:
If it is in list.html, it shows only posts in this particular category. Or it can be put in a separate partial template cats.html