Georg
August 18, 2022, 10:17am
1
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 }}
Georg
August 18, 2022, 4:01pm
3
Thanks a lot, @jmooring . I’m gonna use this .Key
in the next days and report here.
Georg
August 18, 2022, 5:07pm
4
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.
system
Closed
August 20, 2022, 5:08pm
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.