Hugo Tags List

Tags:

A simple snippet i found to fetch all tags, and still to read it up

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{{ if ne .Site.Params.TagsInHome 0 }}

{{ $randTags := (slice)}}
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
{{ $randTags = $randTags | append $name }}
{{ end }}
{{ $randTags = sort (first .Site.Params.TagsInHome (shuffle $randTags)) }}

{{ if gt (len $randTags) 1 }}

<div class="columns is-centered has-text-centered">
    <div class="column is-10">
        <div class="content">
            <a href="{{ "/tags/" | relURL }}">
                <h1>Read articles by tags</h1>
            </a>
            <p class="tags-summary">
                {{ range $name := $randTags }}
                <a href="{{ "/tags/" | relURL }}{{ $name | urlize }}">
                    <span class="tag is-dark is-large is-rounded">
                        {{ replace $name "-" " " | title }}
                    </span>
                </a>
                {{ end }}
            </p>
        </div>
    </div>
</div>
<br>

{{ end }}
{{ end }}

References: https://github.com/rafed/ramium/blob/master/layouts/partials/index/tag-bullet.html

For feedback reach me at email@murarisumit.in