个人博客hugo Taxonomy tags


原文链接: 个人博客hugo Taxonomy tags

生成当前文档的标签列表

{{ if isset .Params "tags" }}
    {{ if gt (len .Params.tags ) 0 }}
    <div class="tags">
        <i class="fa fa-tags"></i>
        {{ range .Params.tags }}
            <a href="/tags/{{ . | urlize }}">{{ . }}</a>
            <!-- <li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li> -->

        {{ end }}
    </div>
    {{ end }}
{{ end }}

根据标签长度设置大小 生成所有标签

  <div class="tagcloud post-tags">
      {{ range $name, $value := .Site.Taxonomies.tags }}
         <a rel="nofollow" rel="tag" href="/tags/{{ $name | urlize }}/" class="tag-link-{{- (sub 11 (len $name)) -}}" title="1 Posts">{{ $name }}<small>({{ .Count }})</small></a>
      {{end}}
  </div>

根据标签数量设置大小

  <div class="tagcloud post-tags">
      {{ range $name, $value := .Site.Taxonomies.tags }}
         <a rel="nofollow" rel="tag" href="/tags/{{ $name | urlize }}/" class="tag-link-{{- .Count -}}" title="1 Posts">{{ $name }}<small>({{ .Count }})</small></a>
      {{end}}
  </div>
    <ul class="meta-single group">
        {{ range .Params.categories }}
        <li class="category">
            <a rel="nofollow" href="/categories/{{ . | urlize }}/" rel="category tag">{{ . }}</a>
        </li>
        {{ end }}
        {{ range .Params.tags }}
            <li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li>
        {{ end }}
        </ul>
`