Post thumbnails not linking to the post

Hi all,

I have a content section called “Photos”.
Inside I have folders for each post, with an index.md file and an some_name.jpg file.
I want to create a page that automatically creates thumbnails from each image in the folder and link to the post.

I have this:

{{ range .RegularPages.ByDate.Reverse }}
	{{ range .Resources }}
  		<div>
			{{ $image := .Resize "1280x q90" }}
			<a href="{{ .Permalink }}"><img src="{{ $image.RelPermalink }}"></a>
  		</div>
	{{ end }}
{{ end }}

It works, as so far that it nicely creates the thumbnails, in the order I want.
But when I click the image, it links to the image url, and not the post url.
So instead of linking to https://someurl/photos/postname it now goes to https://someurl/photos/postname/some_image.jpg

I am sure it is something very simple, but I cannot figure it out…

Thanks for your time.

Jan-Willem

Store the page .Permalink first.

{{ range .RegularPages.ByDate.Reverse }}
  {{ $PagePermalink := .Permalink }}
	{{ range .Resources }}
  		<div>
			{{ $image := .Resize "1280x q90" }}
			<a href="{{ $PagePermalink }}"><img src="{{ $image.RelPermalink }}"></a>
  		</div>
	{{ end }}
{{ end }}
1 Like

Oh my god. Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.