$image.RelPermalink not working

I’m gonna be honest here, I truly have no clue why it’s not working. Let me explain though.

I have images in assets/images. (I’m trying to use those images with image processing.) I’m trying to access them in a custom single page template (layouts/music/single.html) for songs (content/music/songs). In the front matter for songs I have a cover entry which has the name of the file, like this ozone-drive.png. In layouts/music/single.html I use the following code: {{ $image := .Resources.GetMatch .Params.cover }}, which seems to work.

However when I use $image.RelPermalink I get an error: execute of template failed at <$image.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink render of “page” failed.

Anyone a clue on how to fix this?

  • .Resources is Page method to access Page bundle resources
  • resources is global function to access global resources in assets

use {{ resources.Get .Params.cover }}

I still get the same error that way :confused:

Not true, it’s working now. Think it had to do with compilation or cache (or maybe even a typo…).

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