Title
Syntax
RESOURCE.Title
Returns
string
The value returned by the Title
method on a Resource
object depends on the resource type.
Global resource
With a global resource, the Title
method returns the path to the resource, relative to the assets directory.
assets/
└── images/
└── Sunrise in Bryce Canyon.jpg
{{ with resources.Get "images/Sunrise in Bryce Canyon.jpg" }}
{{ .Title }} → /images/Sunrise in Bryce Canyon.jpg
{{ end }}
Page resource
With a page resource, if you create an element in the resources
array in front matter, the Title
method returns the value of the title
parameter.
content/
├── example/
│ ├── images/
│ │ └── a.jpg
│ └── index.md
└── _index.md
content/example/index.md
---
resources:
- src: images/a.jpg
title: A beautiful sunrise in Bryce Canyon
title: Example
---
+++
title = 'Example'
[[resources]]
src = 'images/a.jpg'
title = 'A beautiful sunrise in Bryce Canyon'
+++
{
"resources": [
{
"src": "images/a.jpg",
"title": "A beautiful sunrise in Bryce Canyon"
}
],
"title": "Example"
}
{{ with .Resources.Get "images/a.jpg" }}
{{ .Title }} → A beautiful sunrise in Bryce Canyon
{{ end }}
If you do not create an element in the resources
array in front matter, the Title
method returns the file path, relative to the page bundle.
content/
├── example/
│ ├── images/
│ │ └── Sunrise in Bryce Canyon.jpg
│ └── index.md
└── _index.md
{{ with .Resources.Get "Sunrise in Bryce Canyon.jpg" }}
{{ .Title }} → images/Sunrise in Bryce Canyon.jpg
{{ end }}
Remote resource
With a remote resource, the Title
method returns a hashed file name.
{{ with resources.GetRemote "https://example.org/images/a.jpg" }}
{{ .Title }} → /a_18432433023265451104.jpg
{{ end }}