Site.Data when a [title.1] has a number

I’m not proud of this solution, but then again I am not a coder, Jim.

Since I couldn’t get the folder name any other way, I’m gonna use the file name as the folder (issue-1, issue-2, etc)

{{ $image_path := "themes/magazine/static/img/covers/menu/" }}
{{ $images := readDir $image_path }}

{{ range $images }}
{{ $link := trim .Name ".jpg" }}
     <a href="{{ $link }}"><img src="../img/covers/menu/{{ .Name }}" class="img-fluid w-100"></a>
{{ end }}

Angels will cry, I know. But what else can I do? It works!

I solved it this way


{{range $images }}{{ $original := . }}
...
<img src="../img/covers/menu/{{ $original.RelPermalink }}" class="img-fluid w-100">
...
{{ end }}

PS:
{{ .RelPermalink }} should work too

1 Like