Wildcard match for folders in Hugo Resources?

I have my image assets divided thus:

/assets/
- /images/
-- /articles/
-- /answers
-- /podcast/

All three of these content types - answers, podcasts, and articles - use categories.

On the categories list page, I have the following code to grab the image and pull it into a card:

    {{- $image := printf "/images/articles/%s" .Params.feature -}}
    {{- $image = (resources.Match $image).Resize "400x webp q80" -}}

Obviously this fails to build because sometimes the image is located in /images/answers/ or /images/podcast.

My question is, how can I wild-card that middle folder?

I tried ** but it didn’t work (IE: printf "/images/**/%s" .Params.feature).

resources.Match returns a slice of matching images. Use resources.GetMatch to get a single image.

resources.GetMatch (printf "/images/**/%s" .Params.feature)

1 Like

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