Hugo 没有从 front matter 呈现摘要

Hugo not rendering the summary from the front matter

根据 Hugo content summary guide,我可以用 3 种方式定义摘要(按优先级最高的顺序列出):

  1. 使用 <!--more--> 标签来告诉 Hugo 应该使用文章的多少作为摘要
  2. 在前面的内容中使用 summary 变量以使用自定义摘要
  3. 让Hugo默认使用文章的前70个字

首先,这是我为各个页面准备的模板:

{{ 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!

titledate 渲染得很好,但是,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 前面的内容?

此功能已在 Hugo 0.55.0 via issue #5800 中引入。

升级到Hugo 0.55.0或以上版本解决问题