Blogdown网站发布 - 隐藏帖子的日期和/或标题

Jas*_*Jas 3 r blogdown

我想在运行blogdown :: build_site()后从帖子中删除日期而不必从公用文件夹中手动删除.

我有一个名为Gallery的帖子,它在顶部的Rmarkdown文件中有以下yaml标题:

---
title: Gallery
date: null
output:
  blogdown::html_page:
    date: null
---
Run Code Online (Sandbox Code Playgroud)

这是它在public/gallery/index.html文件中的呈现方式:

<div class="item">
    <h4><a href="/gallery/">Gallery</a></h4>
    <h5>January 1, 0001</h5>
</div>
Run Code Online (Sandbox Code Playgroud)

无论如何要移除/隐藏它而不手动操作?

我正在使用最小的主题https://github.com/calintat/minimal/

TC *_*ang 5

您所要求的并不是主题本身.但是一个简单的调整就行了.

  1. layouts/partials/在您的仓库中创建文件夹(如果它不存在).
  2. 复制themes/minimal/layouts/partials/list-item.htmllayouts/pairtials/list-item.html
  3. 改变这一行:

    <h5>{{ $.Scratch.Get "subtitle" }}</h5>
    
    Run Code Online (Sandbox Code Playgroud)

    {{ if not .Params.hidedate }}<h5>{{ $.Scratch.Get "subtitle" }}</h5>{{ end }}
    
    Run Code Online (Sandbox Code Playgroud)
  4. 在帖子的yaml标题中,添加hidedate: true如下:

    ---
    title: "Creating a New Theme"
    tags: ["go", "golang", "hugo", "themes"]
    hidedate: true
    draft: false
    --- 
    
    Run Code Online (Sandbox Code Playgroud)

这将关闭日期,其他正常帖子不受影响.