hugo - 雨果没有从前面的事情中呈现摘要
问题描述
根据Hugo 内容摘要指南,我可以通过 3 种方式定义摘要(按优先级最高的顺序列出):
- 使用
<!--more-->
标签告诉 Hugo 应该使用多少文章作为摘要 - 使用
summary
前面的变量以使用自定义摘要 - 让 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!
和渲染就好了,但是,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
前面的东西渲染?
解决方案
这个特性是在Hugo 0.55.0中通过issue #5800引入的。
升级到 Hugo 0.55.0 或以上版本解决问题
推荐阅读
- r - gtsummary:堆叠数据框?
- google-cloud-platform - 我可以将 json 文件从 Project_A 推送/加载到 Project_B 的 BigQuery 吗?即跨项目
- docker - 无法在我的容器中安装解压缩工具
- c++ - 如何懒惰地初始化 unique_ptrs 的模板元组?
- android - 整合账户持有状态问题:删除应用程序或切换设备后,历史记录被删除
- node.js - 如何防止网站使用 puppeteer 提出不必要的请求以提高我们程序的性能
- r - R中的伯努利数
- c# - Entity-Framework 6,通过两个ID定义关系
- sql-server - 无法加载文件或程序集“microsoft.visualstudio.shell.ui.internal”或其依赖项之一。无效的指针
- swift - 如何快速找到给定字符串中的第二个范围