Merge commit 'e509cac533600cf4fa8382c9cdab78ddd82db688'

This commit is contained in:
Bjørn Erik Pedersen
2023-10-20 09:43:56 +02:00
298 changed files with 4568 additions and 1991 deletions

View File

@@ -15,4 +15,4 @@ aliases: [/templates/variables/]
Hugo's templates are context aware and make a large number of values available to you as you're creating views for your website.
[Go templates]: /templates/introduction/ "Understand context in Go templates by learning the language's fundamental templating functions."
[Go templates]: /templates/introduction/

View File

@@ -20,7 +20,7 @@ Hugo's Git integrations should be fairly performant but *can* increase your buil
1. The Hugo site must be in a Git-enabled directory.
2. The Git executable must be installed and in your system `PATH`.
3. The `.GitInfo` feature must be enabled in your Hugo project by passing `--enableGitInfo` flag on the command line or by setting `enableGitInfo` to `true` in your [site's configuration file][configuration].
3. The `.GitInfo` feature must be enabled in your Hugo project by passing `--enableGitInfo` flag on the command line or by setting `enableGitInfo` to `true` in your [site's configuration file][configuration].
## The `.GitInfo` object
@@ -52,8 +52,7 @@ If the `.GitInfo` feature is enabled, `.Lastmod` (on `Page`) is fetched from Git
## Hosting considerations
On the site host, your repository must be "deep-cloned," so the returned `.GitInfo` data will be accurate. Otherwise, your site may display only data from your latest commit. Where it's not possible to configure a host's cloning depth, you must handle this through CI/CD (*e.g.*, a
GitHub Action or GitLab CI/CD). See the following table:
On the site host, your repository must be "deep-cloned," so the returned `.GitInfo` data will be accurate. Otherwise, your site may display only data from your latest commit. Where it's not possible to configure a host's cloning depth, you must handle this through CI/CD (*e.g.*, a GitHub Action or GitLab CI/CD). See the following table:
| Hosting service | Clone depth | Configurable? |
| :-------------- | :---------- | :-----------: |

View File

@@ -97,7 +97,7 @@ The following is a list of page-level variables. Many of these will be defined i
: The Permanent link for this page; see [Permalinks](/content-management/urls/)
.Plain
: The Page content stripped of HTML tags and presented as a string. You may need to pipe the result through the [`htmlUnescape`](/functions/htmlunescape/) function when rendering this value with the HTML [output format](/templates/output-formats#output-format-definitions).
: The Page content stripped of HTML tags and presented as a string. You may need to pipe the result through the [`htmlUnescape`](/functions/transform/htmlunescape) function when rendering this value with the HTML [output format](/templates/output-formats#output-format-definitions).
.PlainWords
: The slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields).
@@ -195,7 +195,29 @@ List pages receive the following page collections in [context](/getting-started/
Also see [Sections](/content-management/sections/).
{{< readfile file="/content/en/readfiles/sectionvars.md" markdown="true" >}}
.CurrentSection
: The page's current section. The value can be the page itself if it is a section or the homepage.
.FirstSection
: The page's first section below root, e.g. `/docs`, `/blog` etc.
.InSection $anotherPage
: Whether the given page is in the current section.
.IsAncestor $anotherPage
: Whether the current page is an ancestor of the given page.
.IsDescendant $anotherPage
: Whether the current page is a descendant of the given page.
.Parent
: A section's parent section or a page's section.
.Section
: The [section](/content-management/sections/) this content belongs to. **Note:** For nested sections, this is the first path element in the directory, for example, `/blog/funny/mypost/ => blog`.
.Sections
: The [sections](/content-management/sections/) below this content.
## Page fragments
@@ -230,23 +252,6 @@ Also see the [Go Doc](https://pkg.go.dev/github.com/gohugoio/hugo@v0.111.0/marku
`.Fragments` are safe to call from render hooks, even on the page you're on (`.Page.Fragments`). For shortcodes we recommend that all `.Fragments` usage is nested inside the `{{</**/>}}` shortcode delimiter (`{{%/**/%}}` takes part in the ToC creation so it's easy to end up in a situation where you bite yourself in the tail).
## The global page function
{{< new-in "0.111.1" >}}
Hugo almost always passes a `Page` as the data context into the top level template (e.g. `single.html`) (the one exception is the multihost sitemap template). This means that you can access the current page with the `.` variable in the template.
But when you're deeply nested inside `.Render`, partial etc., accessing that `Page` object isn't always practical or possible.
For this reason, Hugo provides a global `page` function that you can use to access the current page from anywhere in any template.
```go-html-template
{{ page.Title }}
```
There are one caveat with this, and this isn't new, but it's worth mentioning here: There are situations in Hugo where you may see a cached value, e.g. when using `partialCached` or in a shortcode.
## The `.RenderShortcodes` method {#rendershortcodes}
{{< new-in "0.117.0" >}} This renders all the shortcodes in the content, preserving the surrounding markup (e.g. Markdown) as is.

View File

@@ -57,19 +57,19 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo
: a string representing the language tag as defined in the site configuration.
.Site.LanguagePrefix
: this can be used to prefix URLs to point to the correct language. It will even work when there is only one defined language. See also the functions [absLangURL](/functions/abslangurl/) and [relLangURL](/functions/rellangurl).
: this can be used to prefix URLs to point to the correct language. It will even work when there is only one defined language. See also the functions [absLangURL](/functions/urls/abslangurl) and [relLangURL](/functions/urls/rellangurl).
.Site.Languages
: an ordered list (ordered by defined weight) of languages.
.Site.LastChange
: a string representing the date/time of the most recent change to your site. This string is based on the [`date` variable in the front matter](/content-management/front-matter) of your content pages.
: a [time.Time](https://godoc.org/time#Time) value representing the date/time of the most recent change to your site.
.Site.Menus
: all the menus in the site.
.Site.Pages
: array of all content ordered by Date with the newest first. This array contains only the pages in the current language.
: array of all content ordered by Date with the newest first. This array contains only the pages in the current language.
.Site.RegularPages
: a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"`.

View File

@@ -96,7 +96,7 @@ Access the entire taxonomy data structure from any template with `site.Taxonomie
Access a subset of the taxonomy data structure by chaining one or more identifiers, or by using the [`index`] function with one or more keys. For example, to access the collection of weighted content pages related to the news category, use either of the following:
[`index`]: /functions/index-function/
[`index`]: /functions/collections/indexfunction/
```go-html-template
{{ $pages := site.Taxonomies.categories.news }}