Merge commit 'a6e635ca7d905d9ec3ffd708db2694f680b03aae'

This commit is contained in:
Bjørn Erik Pedersen
2024-08-09 15:17:43 +02:00
143 changed files with 3258 additions and 2109 deletions

View File

@@ -36,7 +36,7 @@ content/
└── _index.md
```
This home page template:
This home template:
```go-html-template
{{ with .Site.GetPage "/works/paintings" }}
@@ -96,7 +96,7 @@ content/
└── _index.md
```
In the home page template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle]:
In the home template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle]:
```go-html-template
{{ with .Site.GetPage "/headless" }}

View File

@@ -7,6 +7,7 @@ action:
related: []
returnType: bool
signatures: [SITE.IsMultiLingual]
expiryDate: 2025-03-16 # deprecated 2024-03-16
---
{{% deprecated-in 0.124.0 %}}

View File

@@ -7,6 +7,7 @@ action:
related: []
returnType: time.Time
signatures: [SITE.LastChange]
expiryDate: 2025-02-19 # deprecated 2024-02-19
---
{{% deprecated-in 0.123.0 %}}

View File

@@ -46,7 +46,7 @@ Template:
When creating a theme, instead of hardcoding section names when listing the most relevant pages on the front page, instruct site authors to set `params.mainSections` in their site configuration.
Then your home page template can do something like this:
Then your home template can do something like this:
```go-html-template
{{ range where .Site.RegularPages "Section" "in" .Site.MainSections }}

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/
[`partial`]: /functions/partials/include/
[`partialCached`]: /functions/partials/includecached/

View File

@@ -12,6 +12,10 @@ action:
signatures: [SITE.RegularPages]
---
The `RegularPages` method on a `Site` object returns a collection of all [regular pages].
[regular pages]: /getting-started/glossary/#regular-page
```go-html-template
{{ range .Site.RegularPages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>

View File

@@ -1,6 +1,6 @@
---
title: Taxonomies
description: Returns a data structure containing the site's taxonomy objects, the terms within each taxonomy object, and the pages to which the terms are assigned.
description: Returns a data structure containing the site's Taxonomy objects, the terms within each Taxonomy object, and the pages to which the terms are assigned.
categories: []
keywords: []
action:
@@ -9,6 +9,13 @@ action:
signatures: [SITE.Taxonomies]
---
<!-- TODO
Show template example: GetTerms
-->
Conceptually, the `Taxonomies` method on a `Site` object returns a data structure such&nbsp;as:
{{< code-toggle >}}
@@ -97,3 +104,82 @@ Please see the [taxonomies] section for a complete explanation and examples.
[taxonomies]: /content-management/taxonomies/
{{% /note %}}
## Examples
### List content with the same taxonomy term
If you are using a taxonomy for something like a series of posts, you can list individual pages associated with the same term. For example:
```go-html-template
<ul>
{{ range .Site.Taxonomies.series.golang }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a></li>
{{ end }}
</ul>
```
### List all content in a given taxonomy
This would be very useful in a sidebar as “featured content”. You could even have different sections of “featured content” by assigning different terms to the content.
```go-html-template
<section id="menu">
<ul>
{{ range $term, $taxonomy := .Site.Taxonomies.featured }}
<li>{{ $term }}</li>
<ul>
{{ range $taxonomy.Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
</ul>
</section>
```
### Render a site's taxonomies
The following example displays all terms in a site's tags taxonomy:
```go-html-template
<ul>
{{ range .Site.Taxonomies.tags }}
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
{{ end }}
</ul>
```
This example will list all taxonomies and their terms, as well as all the content assigned to each of the terms.
{{< code file=layouts/partials/all-taxonomies.html >}}
{{ with .Site.Taxonomies }}
{{ $numberOfTerms := 0 }}
{{ range $taxonomy, $terms := . }}
{{ $numberOfTerms = len . | add $numberOfTerms }}
{{ end }}
{{ if gt $numberOfTerms 0 }}
<ul>
{{ range $taxonomy, $terms := . }}
{{ with $terms }}
<li>
<a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a>
<ul>
{{ range $term, $weightedPages := . }}
<li>
<a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a>
<ul>
{{ range $weightedPages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ end }}
{{< /code >}}

View File

@@ -7,6 +7,7 @@ keywords: []
menu:
docs:
parent: methods
aliases: [/variables/site/]
---
Use these methods with Site objects. A multilingual project will have two or more sites, one for each language.