Hi, how are you?
I need some help.
I am trying to setup a related section beneath every post but I can’t get images to show. I’ve tried different things but I keep failing. Here’s the code.
The title and date all work as they should but the images don’t show up
NB:
Actually, I just noticed that the code pulls pages from different sections but seemingly fails to pull from the blog section. I want it to pull them strictly from the blog. I also want it to only show the related articles when they are available
{{ $related := .Site.RegularPages.Related . | first 3 }}
should be (untested)
{{ $blogPosts := where .Site.RegularPages "Type" "blog" }}
{{ $related := $blogPosts.Related | first 3 }}
For the first part of your query:
For that we need to know what .Params.hero is evaluating to, as well as your site structure (and if you have any render hooks that alter the way images are handled).
My desire is to add a Related Posts section just under the comments where visitors could read more articles. I want it to strictly work on my blog as I have 3 other sections. The {{ .Params.hero }} doesn’t show anything but the alt and the image icon(which is supposed to show when the image was not found.) I’ve tried adding $ like this: {{ $.Params.hero }} but it displays the current post’s image, I’ve tried adding {{ $related.Params.hero }} and it fails to deploy, I’ve even tried {{ .Params.hero | absURl }}. But nothing works. hero is supposed to show the related article’s hero as that’s the frontmatter parameter used in the markdown file. Could you kindly help me. I’ve deleted the related.html partial(used to show 3 related posts) as my site couldn’t deploy with the code you gave me.