Just use a slice instead of a scratch utilizing append to build up the list.
{{ $bgImagesLinks := slice }}
{{ range $bgImages }}
{{ $bgImagesLinks = $bgImagesLinks | append .RelPermalink}}
{{ end }}
Or use a string variable and add each string using printf or add. In that case initialize the var with the relpermalink of the first resource and then loop over the rest using after. And add ‘;’ link .
{{ $bgImagesLinks := index $bgImages 0 }}
{{ range after 1 $bgImages }}
{{ $bgImagesLinks = printf "%s;%s" $bgImagesLinks .RelPermalink }}
{{ end }}
# no delimit later cause already a string
# just use $bgImagesLinks
A comment/question on:
First returns an image resource. Shouldn’t it be url('{{ $bgImageCurrent.RelPermalink }}'); in the latter line.
There is a side effect with the auto casting of printf, the asset is not published in public directory. Hugo doc about Asset publishing:
Hugo publishes assets to the publishDir (typically public) when you invoke .Permalink, .RelPermalink, or .Publish. You can use .Content to inline the asset.
So i had .RelPermalink when creating the $bgImagesLinks and it work fine.