[英]Add tags to post summaries of lithium themed hugo blogdown website
使用鏈接到Add template for taxonomies to Blogdown default theme的指南,我能夠添加標簽以顯示在我的帖子頂部並創建一個/tags頁面——用於我的鋰主題 hugo blogdown 網站。
我怎樣才能讓帖子標簽顯示在我的鋰主題網站的摘要中(即它們顯示在主頁上)?
首先,將以下 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;
}
這是我提供的代碼的外觀:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.