Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'

This commit is contained in:
Bjørn Erik Pedersen
2024-06-21 09:41:24 +02:00
475 changed files with 7408 additions and 4720 deletions

View File

@@ -16,7 +16,7 @@ This method returns all page [kinds] in all languages. That includes the home pa
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: methods/site/regularpages
[`RegularPages`]: /methods/site/regularpages/
[kinds]: /getting-started/glossary/#page-kind
```go-html-template

View File

@@ -30,8 +30,8 @@ There is almost never a good reason to use this method in your templates. Its us
Use the [`absURL`], [`absLangURL`], [`relURL`], or [`relLangURL`] functions instead.
[`absURL`]: /functions/urls/absURL
[`absLangURL`]: /functions/urls/absLangURL
[`relURL`]: /functions/urls/relURL
[`relLangURL`]: /functions/urls/relLangURL
[`absURL`]: /functions/urls/absURL/
[`absLangURL`]: /functions/urls/absLangURL/
[`relURL`]: /functions/urls/relURL/
[`relLangURL`]: /functions/urls/relLangURL/
{{% /note %}}

View File

@@ -20,7 +20,7 @@ Use the `Data` method on a `Site` object to access data within the data director
{{% note %}}
Although Hugo can unmarshal CSV files with the [`transform.Unmarshal`] function, do not place CSV files in the data directory. You cannot access data within CSV files using this method.
[`transform.Unmarshal`]: /functions/transform/unmarshal
[`transform.Unmarshal`]: /functions/transform/unmarshal/
{{% /note %}}
Consider this data directory:
@@ -101,8 +101,14 @@ To find a fiction book by ISBN:
{{ end }}
```
In the template examples above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function:
In the template examples above, each of the keys is a valid [identifier]. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function. For example:
[`index`]: /functions/collections/indexfunction
[identifier]: /getting-started/glossary/#identifier
```go-html-template
{{ index .Site.Data.books "historical-fiction" }}
```
[`index`]: /functions/collections/indexfunction/
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -13,5 +13,5 @@ expiryDate: 2024-10-30 # deprecated 2023-10-30
{{% deprecated-in 0.120.0 %}}
Use [`Site.Config.Services.Disqus.Shortname`] instead.
[`Site.Config.Services.Disqus.Shortname`]: /methods/site/config
[`Site.Config.Services.Disqus.Shortname`]: /methods/site/config/
{{% /deprecated-in %}}

View File

@@ -13,7 +13,7 @@ toc: true
The `GetPage` method is also available on `Page` objects, allowing you to specify a path relative to the current page. See [details].
[details]: /methods/page/getpage
[details]: /methods/page/getpage/
When using the `GetPage` method on a `Site` object, specify a path relative to the content directory.

View File

@@ -13,5 +13,5 @@ expiryDate: 2024-10-30 # deprecated 2023-10-30
{{% deprecated-in 0.120.0 %}}
Use [`Site.Config.Services.GoogleAnalytics.ID`] instead.
[`Site.Config.Services.GoogleAnalytics.ID`]: /methods/site/config
[`Site.Config.Services.GoogleAnalytics.ID`]: /methods/site/config/
{{% /deprecated-in %}}

View File

@@ -13,7 +13,7 @@ expiryDate: 2024-10-30 # deprecated 2023-10-30
{{% deprecated-in 0.120.0 %}}
Use [`hugo.IsDevelopment`] instead.
[`hugo.IsDevelopment`]: /functions/hugo/isdevelopment
[`hugo.IsDevelopment`]: /functions/hugo/isdevelopment/
{{% /deprecated-in %}}
```go-html-template

View File

@@ -1,6 +1,6 @@
---
title: IsMultiLingual
description: Reports whether the site is multilingual.
description: Reports whether there are two or more configured languages.
categories: []
keywords: []
action:
@@ -9,6 +9,12 @@ action:
signatures: [SITE.IsMultiLingual]
---
{{% deprecated-in 0.124.0 %}}
Use [`hugo.IsMultilingual`] instead.
[`hugo.IsMultilingual`]: /functions/hugo/ismultilingual/
{{% /deprecated-in %}}
Site configuration:
{{< code-toggle file=hugo >}}

View File

@@ -13,7 +13,7 @@ expiryDate: 2024-10-30 # deprecated 2023-10-30
{{% deprecated-in 0.120.0 %}}
Use [`hugo.IsServer`] instead.
[`hugo.IsServer`]: /functions/hugo/isserver
[`hugo.IsServer`]: /functions/hugo/isserver/
{{% /deprecated-in %}}
```go-html-template

View File

@@ -35,7 +35,7 @@ Lang
```
LanguageCode
: (`string`) The language code from the site configuration.
: (`string`) The language code from the site configuration. Falls back to `Lang` if not defined.
```go-html-template
{{ .Site.Language.LanguageCode }} → de-DE
@@ -68,16 +68,10 @@ Some of the methods above are commonly used in a base template as attributes for
```go-html-template
<html
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
dir="{{ or site.Language.LanguageDirection `ltr` }}
lang="{{ .Site.Language.LanguageCode }}"
dir="{{ or .Site.Language.LanguageDirection `ltr` }}
>
```
The example above uses the global [`site`] function instead of accessing the `Site` object via the `.Site` notation.
Also note that each attribute has a fallback value assigned via the [`or`] operator.
[details]: /methods/page/language
[details]: /methods/page/language/
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[`or`]: /functions/go-template/or
[`site`]: /functions/global/site

View File

@@ -12,10 +12,10 @@ action:
The `Languages` method on a `Site` object returns a collection of language objects for all sites, ordered by language weight. Each language object points to its language definition in the site configuration.
To view the data structure:
To inspect the data structure:
```go-html-template
<pre>{{ jsonify (dict "indent" " ") .Site.Languages }}</pre>
<pre>{{ debug.Dump .Site.Languages }}</pre>
```
With this site configuration:

View File

@@ -9,13 +9,19 @@ action:
signatures: [SITE.LastChange]
---
{{% deprecated-in 0.123.0 %}}
Use [`.Site.Lastmod`] instead.
[`.Site.Lastmod`]: /methods/site/lastmod/
{{% /deprecated-in %}}
The `LastChange` method on a `Site` object returns a [`time.Time`] value. Use this with time [functions] and [methods]. For example:
```go-html-template
{{ .Site.LastChange | time.Format ":date_long" }} → October 16, 2023
{{ .Site.LastChange | time.Format ":date_long" }} → January 31, 2024
```
[`time.Time`]: https://pkg.go.dev/time#Time
[functions]: /functions/time
[methods]: /methods/time
[functions]: /functions/time/
[methods]: /methods/time/

View File

@@ -0,0 +1,23 @@
---
title: Lastmod
description: Returns the last modification date of site content.
categories: []
keywords: []
action:
related: []
returnType: time.Time
signatures: [SITE.Lastmod]
---
{{< new-in 0.123.0 >}}
The `Lastmod` method on a `Site` object returns a [`time.Time`] value. Use this with time [functions] and [methods]. For example:
```go-html-template
{{ .Site.Lastmod | time.Format ":date_long" }} → January 31, 2024
```
[`time.Time`]: https://pkg.go.dev/time#Time
[functions]: /functions/time/
[methods]: /methods/time/

View File

@@ -88,7 +88,7 @@ You will typically render a menu using a partial template. As the active menu en
The example above is simplistic. Please see the [menu templates] section for more information.
[menu templates]: /templates/menu-templates
[menu templates]: /templates/menu-templates/
[`partial`]: /functions/partials/include
[`partialCached`]: /functions/partials/includecached
[`partial`]: /functions/partials/include/
[`partialCached`]: /functions/partials/includecached/

View File

@@ -16,7 +16,7 @@ This method returns all page [kinds] in the current language. That includes the
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: methods/site/regularpages
[`RegularPages`]: /methods/site/regularpages/
[kinds]: /getting-started/glossary/#page-kind
```go-html-template

View File

@@ -33,7 +33,7 @@ Access the custom parameters by [chaining] the [identifiers]:
{{ .Site.Params.author.name }} → John Smith
{{ $layout := .Site.Params.layouts.rfc_1123 }}
{{ .Site.LastChange.Format $layout }} → Tue, 17 Oct 2023 13:21:02 PDT
{{ .Site.Lastmod.Format $layout }} → Tue, 17 Oct 2023 13:21:02 PDT
```
In the template example above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function:
@@ -42,6 +42,6 @@ In the template example above, each of the keys is a valid identifier. For examp
{{ index .Site.Params "copyright-year" }} → 2023
```
[`index`]: /functions/collections/indexfunction
[`index`]: /functions/collections/indexfunction/
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -1,6 +1,6 @@
---
title: Sites
description: Returns a collection of all Site objects, one for each language, ordered by language weight.
description: Returns a collection of all Site objects, one for each language, ordered by default content language then by language weight.
categories: []
keywords: []
action:
@@ -49,10 +49,10 @@ Produces a list of links to each home page:
</ul>
```
To render a link to home page of the primary (first) language:
To render a link to the home page of the site corresponding to the default content language:
```go-html-template
{{ with .Site.Sites.First }}
{{ with .Site.Sites.Default }}
<a href="{{ .Home.Permalink }}">{{ .Title }}</a>
{{ end }}
```

View File

@@ -95,5 +95,5 @@ Hugo's taxonomy system is powerful, allowing you to classify content and create
Please see the [taxonomies] section for a complete explanation and examples.
[taxonomies]: content-management/taxonomies/
[taxonomies]: /content-management/taxonomies/
{{% /note %}}