How to show a list of most used tags

Hello, i would like to show a list of most used tags on my blog, right now im using this and it only shows tags by alphabetical order

</div>
  {{- $.Scratch.Set "myLimit" 0 }}

{{- $tags := .Site.Taxonomies.tags }}

<div class="widget-taglist widget">

    <div class="widget__content">

    {{- range $name, $taxonomy := $tags }}

        {{- $.Scratch.Set "myLimit" (add ($.Scratch.Get "myLimit") 1) }}

        {{- if le ($.Scratch.Get "myLimit") 25 }}

            {{- with $.Site.GetPage (printf "/tags/%s" $name) }}

            <a class="widget-taglist__link widget__link clouds" href="{{ .RelPermalink }}" title="{{ .Title }}">

                {{- .Title -}}{{- if .Site.Params.widgets.tags_counter }} ({{ $taxonomy.Count }}){{ end -}}

            </a>

            {{- end }}

Other will fill in the details, Iā€™m sure, but there is {{ site.Taxonomies.tags.ByCount }}.
`

1 Like
{{ $taxonomy := "tags" }}
{{ range (index site.Taxonomies $taxonomy).ByCount }}
  <a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a> ({{ .Count }})<br>
{{ end }}
3 Likes

thank you, but how do i implement this on the widget above

<div class="widget-taglist widget">
  <div class="widget__content">
    {{- range site.Taxonomies.tags.ByCount }}
      {{- if le .Count 25 }}
        <a class="widget-taglist__link widget__link clouds" href="{{ .Page.RelPermalink }}">
          {{- .Page.LinkTitle }}
          {{- if site.Params.widgets.tags_counter }} ({{ .Count }}){{ end -}}
        </a>
      {{- end }}
    {{- end }}
  </div>
</div>
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.