How to add a featured image from the local page bundle?

I have recently discoverd Hugo.
I am trying to move from a ghost blog to Hugo.
I am using ananke theme which seems good and is the theme commented in the install examples.

I like to have the images associated with a post in the bundle page directory.

It works well with images embedded in the post.(just using ![](image/image1.jpg) or ![](image1.jpg) )

But when you try to use them in the fronmatter using feature_image: “./images/image1.jpg” it does not work.

I have read about how Hugo looks for images, it is suposed to look for them in static/images (it works if you put it there) but I had beleived it looked in the bundle page too.

How does it work? How can a inter an image from the same directory as the page/post as a featured image?

You will need to override the Ananke theme’s template and provide for a way to pick up an image from within a Page Bundle to be used as a featured image.

For example you can name the desired file so that it contains the word featured and then in the template use something like:
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}

See this topic for more: Displaying Featured Images

Also see more about the GetMatch method over here

Ok thank you, I see.
So the way featured images are treated is not bound to hugo itshelf, but depends on the theme you are using.

I am too noob with hugo to be able to modify templates, but I will learn step by step.

Meanwhile i will try to find a theme that fit my needs more closely.

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