将标签添加到 post 锂主题 hugo blogdown 网站摘要

Add tags to post summaries of lithium themed hugo blogdown website

使用链接到 Add template for taxonomies to Blogdown default theme I was able to add tags to show-up at the top of my posts and create a /tags 页面的指南——用于我的锂主题 hugo blogdown 网站。

如何让 post 标签显示在我的锂主题网站的 摘要 中(即它们显示在主页上)?

(https://www.bryanshalloway.com/ ; source code on github)

首先,将以下 HTML 添加到您的 layouts/_default/list.html 模板中,在 <article> 标记内和 <div class="summary">.

之后
{{ with (.GetTerms "tags") }}
    <div class="tags">
    {{ range . }}
      <div class="tag">
        <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
      </div>
    {{ end }}
    </div>
{{ end }}

然后为了让它看起来更好看,你可以添加一些类似这样的CSS:

.tags {
    display: flex;
    flex-flow: row wrap;
    gap: 8px;
}
.tags .tag {
    /* override the `margin: auto;` rule which applies to all divs and iframes,
     * defined in main.css */
    margin: 0;

    font-size: small;
}

这是我提供的代码的样子:

example image