我正在尝试使用Hugo在博客文章的底部显示最多三篇相关文章。
我有一些测试代码,其中我获得了标题和摘要等重要字段的数据,但我无法访问Image。
不确定我做错了什么
{{ $related := .Site.RegularPages.Related . | first 3 }}
{{ with $related }}
<div class="related-content">
<h2>Related content</h2>
<ul class="article-gallery">
{{ range . }}
<li>
<div class="card">
<a class="button" href="{{ .RelPermalink }}">
<img src="" alt ="">
</a>
<div>
<h3>{{ .Title }}</h3>
</div>
<pre>
{{.RelPermalink}}
{{.Title}}
{{.Summary}}
{{.}}
{{.ReadingTime}}
</pre>
<!-- Cannot Access Image -->
<pre>
{{.Image}}
</pre>
</div>
</li>
{{ end }}
</ul>
</div>
{{ end }}发布于 2019-03-01 02:15:34
页面首页中的自定义、用户定义的数据元素需要通过.Params访问
{{ .Params.Image }}注意:有一个预定义的"images“(带有”s“),可以直接访问。你的意思是用它来代替吗?
https://stackoverflow.com/questions/54897819
复制相似问题