Adding commas when using the range function to output taxonomies

I am trying to add commas using the delimit function when pulling taxonomies from a range:

I’d like to use: {{ delimit .Params.tag ", " " and " }}, but am not sure how to add additional function to process the parameter tag. I was hoping not to have to write a bunch of if statements to determine if more commas are needed, I assumed the delimit function had that built in. The following is the code I’d like to use commas and possibly the “and” as well when outputting the tags:

{{ if isset .Params "tag" }}
    <div class="tags">tags:</br>

      {{ range  .Params.tag }}<a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }} </a>{{ end }}
    <div class="content-tags">{{.Summary}}</div>
    {{ end }}
1 Like

Not sure if you’re really wanting to use the delimit function, but you could do this with CSS. You could select the div’s children and style their after pseudo elements to contain comma and target the last child to remove the comma placed on it’s siblings:

    div.tags a:after {
        content: ", ";
    div.tags a:last-child:after {
        content: "";
1 Like