Help on removing itemprop keywords comma at end

Hello, I’m currently stuck on trying to remove a trailing “,” from the following itemprop keywords list.

I’m using itemprop keywords from this issue:

I’ve modified it to remove the “,” from the .IsPage content by tweaking:

<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />


<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ if $index }},{{ end }}{{ $tag }}{{ end }}{{ else }}{{ rang    e $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />

Which works to strip the trailing “,” from the individual .isPage post but on the main home page the “,” is there. I cannot figure out how to exclude this within the range of $term, $val. Can anyone assist?

The goal is to get:

<meta itemprop="keywords" content="key1,key2,key3" />

and not:

<meta itemprop="keywords" content="key1,key2,key3,"/>'


I am not processing yer code, but I thought about two things might jog a solution out of yer head:

  • Passing your keywords through delimit
  • Adding .IsHome to your conditional