diff --git a/content/en/content-management/diagrams.md b/content/en/content-management/diagrams.md index d1ed96ba3..69cafc887 100644 --- a/content/en/content-management/diagrams.md +++ b/content/en/content-management/diagrams.md @@ -10,7 +10,6 @@ menu: weight: 260 toc: true --- -{{< new-in 0.93.0 >}} ## GoAT diagrams (ASCII) diff --git a/content/en/getting-started/glossary.md b/content/en/getting-started/glossary.md index f8cb7d4f3..ed8a67e6f 100644 --- a/content/en/getting-started/glossary.md +++ b/content/en/getting-started/glossary.md @@ -206,7 +206,7 @@ Adaptation of a site to meet language and regional requirements. This includes t {{< new-in 0.123.0 >}} -A page or page resource identifier derived from the file path, excluding its extension and language identifier. This value is neither a file path nor a URL. See [details](/methods/page/path). +A page or page resource identifier derived from the file path, excluding its extension and language identifier. This value is neither a file path nor a URL. Starting with a file path relative to the content directory, Hugo determines the logical path by stripping the file extension and language identifier, converting to lower case, then replacing spaces with hyphens. See [examples](/methods/page/path/#examples). ###### map diff --git a/content/en/methods/page/Path.md b/content/en/methods/page/Path.md index 5c78f8536..e9e3e14fe 100644 --- a/content/en/methods/page/Path.md +++ b/content/en/methods/page/Path.md @@ -38,7 +38,7 @@ To determine the logical path for pages backed by a file, Hugo starts with the f 1. Strips the file extension 2. Strips the language identifier 3. Converts the result to lower case -4. Replaces all spaces with hyphens +4. Replaces spaces with hyphens The value returned by the `Path` method on a `Page` object is independent of content format, language, and URL modifiers such as the `slug` and `url` front matter fields. diff --git a/content/en/methods/resource/Name.md b/content/en/methods/resource/Name.md index 01b75e5b2..bdad85e36 100644 --- a/content/en/methods/resource/Name.md +++ b/content/en/methods/resource/Name.md @@ -1,6 +1,6 @@ --- title: Name -description: Returns the name of the given resource as optionally defined in front matter, falling back to a relative path or hashed file name depending on resource type. +description: Returns the name of the given resource as optionally defined in front matter, falling back to its path. categories: [] keywords: [] action: @@ -25,13 +25,31 @@ assets/ ```go-html-template {{ with resources.Get "images/a.jpg" }} - {{ .Name }} → images/a.jpg + {{ .Name }} → /images/a.jpg {{ end }} ``` ## Page resource -With a [page resource], the `Name` method returns the path to the resource, relative to the page bundle. +With a [page resource], if you create an element in the `resources` array in front matter, the `Name` method returns the value of the `name` parameter: + +{{< code-toggle file=content/posts/post-1.md fm=true >}} +title = 'Post 1' +[[resources]] +src = 'images/a.jpg' +name = 'cat' +title = 'Felix the cat' +[resources.params] +temperament = 'malicious' +{{< /code-toggle >}} + +```go-html-template +{{ with .Resources.Get "cat" }} + {{ .Name }} → cat +{{ end }} +``` + +If you do not create an element in the `resources` array in front matter, the `Name` method returns the [logical path] to the resource, relative to the page bundle. ```text content/ @@ -49,34 +67,17 @@ content/ {{ .Name }} → images/a.jpg {{ end }} ``` - -If you create an element in the `resources` array in front matter, the `Name` method returns the value of the `name` parameter: - -{{< code-toggle file=content/posts/post-1.md fm=true >}} -title = 'Post 1' -[[resources]] -src = 'images/a.jpg' -name = 'cat' -title = 'Felix the cat' -[resources.params] -temperament = 'malicious' -{{< /code-toggle >}} - -```go-html-template -{{ with .Resources.Get "cat" }} - {{ .Name }} → cat -{{ end }} -``` ## Remote resource With a [remote resource], the `Name` method returns a hashed file name. ```go-html-template {{ with resources.GetRemote "https://example.org/images/a.jpg" }} - {{ .Name }} → a_18432433023265451104.jpg + {{ .Name }} → /a_18432433023265451104.jpg {{ end }} ``` [global resource]: /getting-started/glossary/#global-resource +[logical path]: /getting-started/glossary/#logical-path [page resource]: /getting-started/glossary/#page-resource [remote resource]: /getting-started/glossary/#remote-resource