I’m trying to add a featured image to my templates but I run into the following error.
Failed to render pages: render of "home" failed: "/[...]/layouts/index.html:7:24": execute of template failed: template: index.html:7:24: executing "main" at <resources.Get>: error calling Get: dirs not supported resource types: &{0xc0010b3330 map[baseDir:/[...] filename:assets isOrdered:false lang: module:project mountRoot: mountWeight:2 opener:0x4833e70 watch:true]}
My posts have following config
—
title: “Title?”
date: 2020-07-05T09:42:49+02:00
draft: false
tags: [“Tag”,“Tag2”]
images:
- “img/image.jpg”
featured_image: “/images/image.jpg”
—
The images is in assets/images.
I have tried numerous ways
Attempt 1
{{ $src := .Params.featured_image }}
{{ $res := resources.Get ($src) }}
Attempt 2
{{ src := .Param “featured_image” }}
{{ $res := resources.Get ($src) }}
Attempt 3
{{ $src := .Params.featured_image }}
{{ $res := resources.Get ( .Params.featured_image) }}
Attempt 4 Returns nil error
{{ $src := resources.GetMatch (printf “**%s” .Params.featured_image) }}
And a bunch more. Only method that works is actually hardcoding the image path.
Only way that works
{{ $res := resources.Get "images/image.jpg }}
How can I get this sorted?
PS
I don’t want to use page bundles since I just want to write blog posts as title.md and put them in my posts folder. Not use page bundles since they are convoluted. Not that I can get param based images to work with page bundles either. Same issues.