Include an image in the post title

Hello
I’m new to Hugo but am a regular user of golang and its templating system, and have a nodding acquaintance with markdown.

I’m building a document site to support an app I wrote in go.

I’m using the hugo-book theme.

I’m up to the point where I can create posts, which are listed in the contents list in a kind of right sidebar

Each post has a title (obviously) and in some cases, it would be best if this title displayed an icon, instead of (or as well as) text.

So for example, mysite/content/docs/icons/bars/bars.md contains the following code:

 title: "Bars"
 weight: 1
 image: "postbar.png"
 
 # Navigation
 
 A bar
 ![Bar](/bar.png)

This results in an entry called ‘Bars’ in the Table of Contents. Instead, I would like to display the icon itself, which is stored as postbar.png in what I hope is in the same leaf as buttons.md.

Is there an idiomatic way to do this (for example via the site or post settings) rather than editing the template files?

Best
Alan

When posting code, configuration, or data on this forum, please wrap the text within triple backticks or use the </> button in the menu.

```
my code
```

Sure, done

Couldn’t figure out how to flag as code so I followed the StackExchange convention i’m used to, which is to indent code blocks by four spaces. Thanks for the tip.

No, there is not.

Thanks!
If someone can point me to any documentation or previous discussion on how to achieve this by editing templates that would be useful. As mentioned, though familiar with Golang templating, I’m on a steep learning curve as regards Hugo (though it’s clearly a great system and I found it very easy to get started)

Found with: Search results for 'Icon in menu' - HUGO

Both prompt and useful. Many thanks. I will close the question and start another if need be, rather than leaving this hanging.

1 Like

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