根据Hugo content summary guide,我可以用3种方式定义摘要(按优先级最高的顺序列出):
<!--more-->
标签来告知Hugo应该使用多少篇文章作为摘要summary
变量以使用自定义摘要首先,这是我为各个页面准备的模板:
{{ partial "header" . }}
{{ partial "nav" . }}
<section class="section">
<div class="container">
<div class="subtitle tags is-6 is-pulled-right">
{{ if .Params.tags }}
{{ partial "tags" .Params.tags }}
{{ end }}
</div>
{{if not .Date.IsZero }}
<h2 class="subtitle is-6">{{ .Date.Format "January 2, 2006" }}</h2>
{{ end }}
<h1 class="title">{{ .Title }}</h1>
{{ if .Site.Params.Info.related }}
<div class="related">{{ partial "related" . }}</div>
{{ end }}
<div class="content">
<h1 id="summary">Summary</h1>
{{ .Summary }}
<h1 id="toc">Table of Contents</h1>
{{ .TableOfContents }}
{{ .Content }}
</div>
</div>
</section>
{{ partial "footer" . }}
这是我撰写的示例文章:
---
title: "Test"
date: 2019-11-23T19:51:44-06:00
draft: true
summary: "This is a simple placeholder summary defined in the front matter"
---
This is a simple placeholder written in the article
# Section 1
Hello world!
title
和date
呈现得很好,但是summary
被忽略,文章中的单词被用作摘要:
然后我像这样使用<!--more-->
标签:
---
title: "Test"
date: 2019-11-23T19:51:44-06:00
draft: true
summary: "This is a simple placeholder summary defined in the front matter"
---
This is a simple placeholder written in the article
<!--more-->
# Section 1
Hello world!
它就像一种魅力...
因此,用于内容摘要的方法1和3起作用,但是方法2无效。我为什么无法呈现summary
前件?
答案 0 :(得分:0)
升级雨果解决了这个问题