Original filename of named page resource?

Hello everybody,

Is there a way to get the original filename of a file, which has been given a new name as a page resource in the front-matter?

I would appreciate any hint, because I couldn’t figure out an easy way reading the docs.

Thanks,
Georg

structure

content/
└── post/
    └── test/
        ├── images/
        │   └── a.jpg
        └── index.md

content/post/test/index.md

+++
title = 'Test'
date = 2022-08-18T08:12:38-07:00
draft = false
[[resources]]
name = 'kitten'
src = 'images/a.jpg'
+++

layouts/_default/single.html

{{ with .Resources.Get "kitten" }}
  {{ .Name }}            --> kitten
  {{ .Key }}             --> /post/test/images/a.jpg
  {{ .Key | path.Base }} --> a.jpg
{{ end }}

Thanks a lot, @jmooring. I’m gonna use this .Key in the next days and report here.

Yes, that’s the best solution. While playing around I saw, that the .Title also still contains the original filename. But its gone, when the title parameter of the resource is also explicitly set like the name.

Thanks again.

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