Files
hugoDocs/content/en/methods/page/String.md
T
2024-12-17 10:30:48 -08:00

1.3 KiB

title, description, categories, keywords, action, toc
title description categories keywords action toc
String Returns the absolute path to the file backing the given page.
related returnType signatures
string
PAGE.String
true

{{< new-in 0.137.0 >}}

With content from the file system:

{{ .String }} → /home/user/project/content/posts/post-1.md

With content from a content adapter:

{{ .String }} → /home/user/project/content/posts/_content.gotmpl:/posts/post-1.md

With content from a module:

{{ .String }}  → /home/user/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/user/hugo-module-content@v0.1.9/content/posts/post-1.md

Use this method to provide useful information when displaying error and warning messages in the console:

{{< code file="layouts/partials/featured-image.html" lang="go-html-template" >}} {{ with .Resources.GetMatch "featured" }} {{ with .Resize "300x webp" }} {{ end }} {{ else }} {{ errorf "The featured-image partial was unable to find a featured image. See %s" .String }} {{ end }} {{< /code >}}

With shortcodes and render hooks use the Position method instead. Note that the Position method is not available to heading, image, and link render hooks.