雨果没有从正面渲染摘要

标签 hugo

根据Hugo content summary guide ,我可以通过 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!
    
    titledate渲染就好了,但是,summary被忽略,文章中的词用作摘要:

    enter image description here

    然后我使用了 <!--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!
    

    它就像一个魅力......

    enter image description here

    因此,内容摘要的方法 1 和 3 有效,但方法 2 无效。我无法获得 summary 的原因是什么?前端要渲染吗?

    最佳答案

    此功能是在 Hugo 0.55.0 中引入的通过 issue #5800 .

    升级到 Hugo 0.55.0 或更高版本 解决问题

    关于雨果没有从正面渲染摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59014231/

    相关文章:

    Hugo Page 资源 - 找不到匹配项

    ubuntu - 安装 snap "core"(3604) ([start snap-core-3604.mount] 失败

    html - Hugo 需要主题吗?

    jekyll - 为什么在常规打包器(Webpack/Parcel)上使用 Hugo 等静态站点生成器?

    html - Hugo 中自动生成的页面

    r - 有没有一种简单的方法可以在 blogdown 主题的主页上添加标题下的摘要?

    github-pages - README.md 在 github 页面显示为索引文件 [hugo 博客引擎部署]

    gulp - 如何在 Netlify 上运行 Gulp 任务

    RStudio blogdown 在首页生成空的 "Posts"链接

    javascript - 将登录页面集成到hugo