forked from gohugoio/hugoDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes gohugoio#2385
- Loading branch information
Showing
21 changed files
with
298 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: fmt.Warnidf | ||
description: Log a suppressable WARNING from a template. | ||
categories: [] | ||
keywords: [] | ||
action: | ||
aliases: [warnidf] | ||
related: | ||
- functions/fmt/Errorf | ||
- functions/fmt/Erroridf | ||
- functions/fmt/Warnf | ||
returnType: string | ||
signatures: ['fmt.Warnidf ID FORMAT [INPUT]'] | ||
aliases: [/functions/warnidf] | ||
--- | ||
|
||
{{< new-in 0.123.0 >}} | ||
|
||
{{% include "functions/fmt/_common/fmt-layout.md" %}} | ||
|
||
The `warnidf` function evaluates the format string, then prints the result to the WARNING log. Unlike the [`warnf`] function, you may suppress warnings logged by the `warnidf` function by adding the message ID to the `ignoreLogs` array in your site configuration. | ||
|
||
This template code: | ||
|
||
```go-html-template | ||
{{ warnidf "warning-42" "You should consider fixing this." }} | ||
``` | ||
|
||
Produces this console log: | ||
|
||
```text | ||
WARN You should consider fixing this. | ||
You can suppress this warning by adding the following to your site configuration: | ||
ignoreLogs = ['warning-42'] | ||
``` | ||
|
||
To suppress this message: | ||
|
||
{{< code-toggle file=hugo >}} | ||
ignoreLogs = ["warning-42"] | ||
{{< /code-toggle >}} | ||
|
||
[`warnf`]: /functions/fmt/warnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Path | ||
description: Returns the canonical content path for the given page. | ||
categories: [] | ||
keywords: [] | ||
action: | ||
related: [] | ||
returnType: string | ||
signatures: [PAGE.Path] | ||
--- | ||
|
||
The `Path` method on a `Page` object returns the canonical content path for the given page, regardless of whether the page is backed by a file. | ||
|
||
```go-html-template | ||
{{ .Path }} → /posts/post-1 | ||
``` | ||
|
||
This value is neither a file path nor a relative URL. It is canonical identifier for each page, independent of content format and URL. | ||
|
||
{{% note %}} | ||
Beginning with the release of [v0.92.0] in January 2022, Hugo emitted a warning whenever the `Path` method was called. The warning indicated that this method would change in a future release. | ||
|
||
The meaning of, and value returned by, the `Path` method on a `Page` object changed with the release of [v0.123.0] in February 2024. | ||
|
||
[v0.92.0]: https://github.com/gohugoio/hugo/releases/tag/v0.92.0 | ||
[v0.123.0]: https://github.com/gohugoio/hugo/releases/tag/v0.123.0 | ||
{{% /note %}} | ||
|
||
For example, if you were to change a page's URL by specifying either `slug` or `url` in front matter, the value returned by the `Path` method will not change: | ||
|
||
File path|Front matter slug|Value returned by .Path | ||
:--|:--|:-- | ||
`content/_index.md`||`/` | ||
`content/posts/_index.md`||`/posts` | ||
`content/posts/post-1.md`|`foo`|`/posts/post-1` | ||
`content/posts/post-2.html`|`bar`|`/posts/post-2` | ||
|
||
With multilingual sites, for languages other than the default content language, Hugo appends a language identifier. For example, for a site where the default content language is English: | ||
|
||
File path|Value returned by .Path | ||
:--|:-- | ||
`content/_index.en.md`|`/` | ||
`content/_index.de.md`|`/_index.de` | ||
`content/posts/_index.en.md`|`/posts` | ||
`content/posts/_index.de.md`|`/posts/_index.de` | ||
`content/posts/posts-1.en.md`|`/posts/post-1` | ||
`content/posts/posts-1.de.md`|`/posts/post-1.de` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.