Nice to have a set of tags on your post, that are clickable and correctly comma delimited … meaning the last tag doesnt get a comma.


tags: [tag1], [tag2], [tag3]

what we dont want

tags: [tag1], [tag2], [tag3],

Here’s the old code that worked with the extra comma after the last tag.

    <span class="inline-item"><a href="/tags/{{ . | urlize }}">{{ . }}</a>,</span>

Here's the correct code - with a full stop at the end - remove it if you think it doesn't fit your style.   

    <span class="inline-item text-black tags">
    {{ range $key, $value := $.Params.tags }}
        <a href="/tags/{{ $value | urlize }}">{{ $value }}</a>{{ if ne $key (sub (len $.Params.tags) 1) }}, {{ else }}.{{ end }}
    {{ end }}