【问题标题】:Add tags to post summaries of lithium themed hugo blogdown website添加标签以发布以锂为主题的hugo blogdown网站的摘要
【发布时间】:2022-05-04 06:05:32
【问题描述】:

使用链接到 Add template for taxonomies to Blogdown default theme 的指南,我能够添加标签以显示在我的帖子顶部并创建一个 /tags 页面 - 用于我的锂主题 Hugo 博客网站。

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

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

【问题讨论】:

    标签: html r r-markdown hugo blogdown


    【解决方案1】:

    首先,将以下 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

    【讨论】:

    • 完美!谢谢!感谢您提供如此明确的指示。
    猜你喜欢
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多