Featured images from static or assets when using page bundles

Hello everyone, happy 2025. I have a question, and I think i know the answer but I would love a confirmation.

Is it possible to set a featured image that resides in the static or assets folder? I want to be able to reuse featured images as sometimes they apply to more than one post and the way i’m formulating my blog this would just save me a step. Currently, the featured image always looks into the page bundle and I haven’t figured out a way to point to the static folder. Any way to tweak this feature? Thanks!

yes you can. what was your guess?

  • assets using resourcesGet

  • static by referencing the absolute path

name could be calculated

  • by page name, title, …
  • by a params.featuredImage = img1.png

i would go with the resources option

for more info choose an option and if you cannot get thing up, elaborate on the topic following Requesting Help

p.s. keep in mind that there is no featured image in hugo. its part of a theme or your own templates

1 Like

Oh that is interesting. I built this theme from scratch and I guess I didn’t realize that I had just made up that resource. This is what happens when you come from wordpress, you get all wordpress brained.

So then your favorite option of using resourcesGet won’t work because, as far as I know, you can’t use short codes in front matter, and that is where I’m defining the “featured image.”

So maybe my question should have formulated differently. How can you call resource in front matter that resides outside the page bundle?

implies you can do that within a page bundle? but you cannot, there’s no such thing like dynamic code in frontmatter with hugo.

if you have a parameter in frontmatter like featuredImage = 'myimg.png' you would write

  • a shortcode for markdown usage (if the author should control placement)
  • a partial template that’s called by a layout adding the stuff to the page (or a card component …)

and in both, shortcodes and partials you can access assets or static images

Right. Currently, I have a partial that displays all posts in a formatted, paginated page. This is where the featured image is being pulled. Instead of copying the same featured image multiple times into multiple page bundles, I’d love to be able to do something like

So what I think I need to do is add ANOTHER front matter variable that lets you flag a standard thumbnail, and then in my list code, it should check for standardThumbnail and resource match that, if it doesn’t find it check for featured image, if it doesn’t find THAT, then it uses the default thumbnail (the last 2/3 of that is already there).

Would be nice if you could access system wide resources in frontmatter though!

thats the place where you can also access global resources.

looks like we don’t match in wording. you cannot fetch a page resource in front matter. you can only give fe. the path and then in a template evaluate that path… it’s just the way how you evaluate the frontmatter value

guess a compilable example of your page bundle could be easily changed to using images from assets