How to customise summary html in anake theme

Hi there,

I’m new to Hugo and really enjoying it so far, although I have much to learn!

I’ve copied the default Anake list/summary html files into my layouts folder in order to customise them and that’s all working fine.

As you can see in the screenshot I’ve used if statements in order to specify the image I want to use rather than the featured image, as is the default behviour of the Anake theme.

This is all works fine but I’m sure there’s a better way! Ideally there would be an additional parameter in the posts front matter that I could use where I can specify a second image path. Then all I would need to do is refer to this parameter in my summary.html with no need for if statements. Is there a way to do this?

Instead of using if .Title, use if .param.whatever and set whatever to the name of your image. Then use that value directly or with Resources.GetMatch (depending on _whereÄ the image should reside – I’d always put it in the page bundle, though) in your summarize template to get the image itself.
And maybe read about page bundles and page parameters in the documentation (and in the forum, where you’ll often find better explanations and examples).

1 Like

Great, thanks for this. I’ve found the docs about page parameters as you suggested and now it’s all working. I added a ‘headshot’ parameter to my posts that has the path to the post specific image and I can access it using .Params.headshot.

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