Add tags to post summaries of lithium themed hugo blogdown website

Viewed 104
1 Answers

First, add the following HTML to your layouts/_default/list.html template, inside the <article> tag and after the <div class="summary">.

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

Then to make it look better, you can add some CSS similar to this:

.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;
}

Here is how it looks with the code I provided:

example image

Related