docs: Prepare for new sub tree

See #11925
This commit is contained in:
Bjørn Erik Pedersen
2024-01-27 10:47:28 +01:00
parent 1083bf7c08
commit fc7de7136a
1157 changed files with 0 additions and 64232 deletions

View File

@@ -1,26 +0,0 @@
---
title: AllPages
description: Returns a collection of all pages in all languages.
categories: []
keywords: []
action:
related:
- methods/site/Pages
- methods/site/RegularPages
- methods/site/Sections
returnType: page.Pages
signatures: [SITE.AllPages]
---
This method returns all page [kinds] in all languages. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: methods/site/regularpages
[kinds]: /getting-started/glossary/#page-kind
```go-html-template
{{ range .Site.AllPages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -1,37 +0,0 @@
---
title: BaseURL
description: Returns the base URL as defined in the site configuration.
categories: []
keywords: []
action:
related:
- functions/urls/AbsURL
- functions/urls/AbsLangURL
- functions/urls/RelURL
- functions/urls/RelLangURL
returnType: string
signatures: [SITE.BaseURL]
---
Site configuration:
{{< code-toggle file=hugo >}}
baseURL = 'https://example.org/docs/'
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.BaseURL }} → https://example.org/docs/
```
{{% note %}}
There is almost never a good reason to use this method in your templates. Its usage tends to be fragile due to misconfiguration.
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
{{% /note %}}

View File

@@ -1,28 +0,0 @@
---
title: BuildDrafts
description: Reports whether the current build includes draft pages.
categories: []
keywords: []
action:
related: []
returnType: bool
signatures: [SITE.BuildDrafts]
---
By default, draft pages are not published when building a site. You can change this behavior with a command line flag:
```sh
hugo --buildDrafts
```
Or by setting `buildDrafts` to `true` in your site configuration:
{{< code-toggle file=hugo >}}
buildDrafts = true
{{< /code-toggle >}}
Use the `BuildDrafts` method on a `Site` object to determine the current configuration:
```go-html-template
{{ .Site.BuildDrafts }} → true
```

View File

@@ -1,57 +0,0 @@
---
title: Config
description: Returns a subset of the site configuration.
categories: []
keywords: []
action:
related: []
returnType: page.SiteConfig
signatures: [SITE.Config]
toc: true
---
The `Config` method on a `Site` object provides access to a subset of the site configuration, specifically the `services` and `privacy` keys.
## Services
These are the default service settings, typically used by Hugo's built-in templates and shortcodes.
{{< code-toggle config=services />}}
For example, to use Hugo's built-in Google Analytics template you must add a [Google tag ID]:
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
{{< code-toggle file=hugo >}}
[services.googleAnalytics]
id = 'G-XXXXXXXXX'
{{< /code-toggle >}}
To access this value from a template:
```go-html-template
{{ .Site.Config.Services.GoogleAnalytics.ID }} → G-XXXXXXXXX
```
You must capitalize each identifier as shown above.
## Privacy
These are the default privacy settings, typically used by Hugo's built-in templates and shortcodes:
{{< code-toggle config=privacy />}}
For example, to disable usage of the built-in YouTube shortcode:
{{< code-toggle file=hugo >}}
[privacy.youtube]
disable = true
{{< /code-toggle >}}
To access this value from a template:
```go-html-template
{{ .Site.Config.Privacy.YouTube.Disable }} → true
```
You must capitalize each identifier as shown above.

View File

@@ -1,22 +0,0 @@
---
title: Copyright
description: Returns the copyright notice as defined in the site configuration.
categories: []
keywords: []
action:
related: []
returnType: string
signatures: [SITE.Copyright]
---
Site configuration:
{{< code-toggle file=hugo >}}
copyright = '© 2023 ABC Widgets, Inc.'
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.Copyright }} → © 2023 ABC Widgets, Inc.
```

View File

@@ -1,108 +0,0 @@
---
title: Data
description: Returns a data structure composed from the files in the data directory.
categories: []
keywords: []
action:
related:
- functions/collections/IndexFunction
- functions/transform/Unmarshal
- functions/collections/Where
- functions/collections/Sort
returnType: map
signatures: [SITE.Data]
---
Use the `Data` method on a `Site` object to access data within the data directory, or within any directory [mounted] to the data directory. Supported data formats include JSON, TOML, YAML, and XML.
[mounted]: /hugo-modules/configuration/#module-configuration-mounts
{{% 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
{{% /note %}}
Consider this data directory:
```text
data/
├── books/
│ ├── fiction.yaml
│ └── nonfiction.yaml
├── films.json
├── paintings.xml
└── sculptures.toml
```
And these data files:
{{< code file=data/books/fiction.yaml lang=yaml >}}
- title: The Hunchback of Notre Dame
author: Victor Hugo
isbn: 978-0140443530
- title: Les Misérables
author: Victor Hugo
isbn: 978-0451419439
{{< /code >}}
{{< code file=data/books/nonfiction.yaml lang=yaml >}}
- title: The Ancien Régime and the Revolution
author: Alexis de Tocqueville
isbn: 978-0141441641
- title: Interpreting the French Revolution
author: François Furet
isbn: 978-0521280495
{{< /code >}}
Access the data by [chaining] the [identifiers]:
```go-html-template
{{ range $category, $books := .Site.Data.books }}
<p>{{ $category | title }}</p>
<ul>
{{ range $books }}
<li>{{ .title }} ({{ .isbn }})</li>
{{ end }}
</ul>
{{ end }}
```
Hugo renders this to:
```html
<p>Fiction</p>
<ul>
<li>The Hunchback of Notre Dame (978-0140443530)</li>
<li>Les Misérables (978-0451419439)</li>
</ul>
<p>Nonfiction</p>
<ul>
<li>The Ancien Régime and the Revolution (978-0141441641)</li>
<li>Interpreting the French Revolution (978-0521280495)</li>
</ul>
```
To limit the listing to fiction, and sort by title:
```go-html-template
<ul>
{{ range sort .Site.Data.books.fiction "title" }}
<li>{{ .title }} ({{ .author }})</li>
{{ end }}
</ul>
```
To find a fiction book by ISBN:
```go-html-template
{{ range where .Site.Data.books.fiction "isbn" "978-0140443530" }}
<li>{{ .title }} ({{ .author }})</li>
{{ 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:
[`index`]: /functions/collections/indexfunction
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -1,17 +0,0 @@
---
title: DisqusShortname
description: Returns the Disqus shortname as defined in the site configuration.
categories: []
keywords: []
action:
related: []
returnType: string
signatures: [SITE.DisqusShortname]
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
{{% /deprecated-in %}}

View File

@@ -1,109 +0,0 @@
---
title: GetPage
description: Returns a Page object from the given path.
categories: []
keywords: []
action:
related:
- methods/page/GetPage
returnType: page.Page
signatures: [SITE.GetPage PATH]
toc: true
---
The `GetPage` method is also available on `Page` objects, allowing you to specify a path relative to the current page. See&nbsp;[details].
[details]: /methods/page/getpage
When using the `GetPage` method on a `Site` object, specify a path relative to the content directory.
If Hugo cannot resolve the path to a page, the method returns nil.
Consider this content structure:
```text
content/
├── works/
│ ├── paintings/
│ │ ├── _index.md
│ │ ├── starry-night.md
│ │ └── the-mona-lisa.md
│ ├── sculptures/
│ │ ├── _index.md
│ │ ├── david.md
│ │ └── the-thinker.md
│ └── _index.md
└── _index.md
```
This home page template:
```go-html-template
{{ with .Site.GetPage "/works/paintings" }}
<ul>
{{ range .Pages }}
<li>{{ .Title }} by {{ .Params.artist }}</li>
{{ end }}
</ul>
{{ end }}
```
Is rendered to:
```html
<ul>
<li>Starry Night by Vincent van Gogh</li>
<li>The Mona Lisa by Leonardo da Vinci</li>
</ul>
```
To get a regular page instead of a section page:
```go-html-template
{{ with .Site.GetPage "/works/paintings/starry-night" }}
{{ .Title }} → Starry Night
{{ .Params.artist }} → Vincent van Gogh
{{ end }}
```
## Multilingual projects
With multilingual projects, the `GetPage` method on a `Site` object resolves the given path to a page in the current language.
To get a page from a different language, query the `Sites` object:
```go-html-template
{{ with where .Site.Sites "Language.Lang" "eq" "de" }}
{{ with index . 0 }}
{{ with .GetPage "/works/paintings/starry-night" }}
{{ .Title }} → Sternenklare Nacht
{{ end }}
{{ end }}
{{ end }}
```
## Page bundles
Consider this content structure:
```text
content/
├── headless/
│ ├── a.jpg
│ ├── b.jpg
│ ├── c.jpg
│ └── index.md <-- front matter: headless = true
└── _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]:
```go-html-template
{{ with .Site.GetPage "/headless" }}
{{ range .Resources.ByType "image" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
```
[page bundle]: /getting-started/glossary/#page-bundle

View File

@@ -1,17 +0,0 @@
---
title: GoogleAnalytics
description: Returns the Google Analytics tracking ID as defined in the site configuration.
categories: []
keywords: []
action:
related: []
returnType: string
signatures: [SITE.GoogleAnalytics]
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
{{% /deprecated-in %}}

View File

@@ -1,25 +0,0 @@
---
title: Home
description: Returns the home Page object for the given site.
categories: []
keywords: []
action:
related: []
returnType: page.Page
signatures: [SITE.Home]
---
This method is useful for obtaining a link to the home page.
Site configuration:
{{< code-toggle file=hugo >}}
baseURL = 'https://example.org/docs/'
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.Home.Permalink }} → https://example.org/docs/
{{ .Site.Home.RelPermalink }} → /docs/
```

View File

@@ -1,21 +0,0 @@
---
title: IsDevelopment
description: Reports whether the current running environment is “development”.
categories: []
keywords: []
action:
related: []
returnType: bool
signatures: [SITE.IsDevelopment]
expiryDate: 2024-10-30 # deprecated 2023-10-30
---
{{% deprecated-in 0.120.0 %}}
Use [`hugo.IsDevelopment`] instead.
[`hugo.IsDevelopment`]: /functions/hugo/isdevelopment
{{% /deprecated-in %}}
```go-html-template
{{ .Site.IsDevelopment }} → true/false
```

View File

@@ -1,34 +0,0 @@
---
title: IsMultiLingual
description: Reports whether the site is multilingual.
categories: []
keywords: []
action:
related: []
returnType: bool
signatures: [SITE.IsMultiLingual]
---
Site configuration:
{{< code-toggle file=hugo >}}
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = true
[languages]
[languages.de]
languageCode = 'de-DE'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
languageCode = 'en-US'
languageName = 'English'
title = 'Project Documentation'
weight = 2
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.IsMultiLingual }} → true
```

View File

@@ -1,21 +0,0 @@
---
title: IsServer
description: Reports whether the built-in development server is running.
categories: []
keywords: []
action:
related: []
returnType: bool
signatures: [SITE.IsServer]
expiryDate: 2024-10-30 # deprecated 2023-10-30
---
{{% deprecated-in 0.120.0 %}}
Use [`hugo.IsServer`] instead.
[`hugo.IsServer`]: /functions/hugo/isserver
{{% /deprecated-in %}}
```go-html-template
{{ .Site.IsServer }} → true/false
```

View File

@@ -1,83 +0,0 @@
---
title: Language
description: Returns the language object for the given site.
categories: []
keywords: []
action:
related:
- methods/page/language
returnType: langs.Language
signatures: [SITE.Language]
toc: true
---
The `Language` method on a `Site` object returns the language object for the given site. The language object points to the language definition in the site configuration.
You can also use the `Language` method on a `Page` object. See&nbsp;[details].
## Methods
The examples below assume the following in your site configuration:
{{< code-toggle file=hugo >}}
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
weight = 1
{{< /code-toggle >}}
Lang
: (`string`) The language tag as defined by [RFC 5646].
```go-html-template
{{ .Site.Language.Lang }} → de
```
LanguageCode
: (`string`) The language code from the site configuration.
```go-html-template
{{ .Site.Language.LanguageCode }} → de-DE
```
LanguageDirection
: (`string`) The language direction from the site configuration, either `ltr` or `rtl`.
```go-html-template
{{ .Site.Language.LanguageDirection }} → ltr
```
LanguageName
: (`string`) The language name from the site configuration.
```go-html-template
{{ .Site.Language.LanguageName }} → Deutsch
```
Weight
: (`int`) The language weight from the site configuration which determines its order in the slice of languages returned by the `Languages` method on a `Site` object.
```go-html-template
{{ .Site.Language.Weight }} → 1
```
## Example
Some of the methods above are commonly used in a base template as attributes for the `html` element.
```go-html-template
<html
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
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
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[`or`]: /functions/go-template/or
[`site`]: /functions/global/site

View File

@@ -1,53 +0,0 @@
---
title: LanguagePrefix
description: Returns the URL language prefix, if any, for the given site.
categories: []
keywords: []
action:
related:
- functions/urls/AbsLangURL
- functions/urls/RelLangURL
returnType: string
signatures: [SITE.LanguagePrefix]
---
Consider this site configuration:
{{< code-toggle file=hugo >}}
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = false
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Project Documentation'
weight = 2
{{< /code-toggle >}}
When visiting the German language site:
```go-html-template
{{ .Site.LanguagePrefix }} → ""
```
When visiting the English language site:
```go-html-template
{{ .Site.LanguagePrefix }} → /en
```
If you change `defaultContentLanguageInSubdir` to `true`, when visiting the German language site:
```go-html-template
{{ .Site.LanguagePrefix }} → /de
```
You may use the `LanguagePrefix` method with both monolingual and multilingual sites.

View File

@@ -1,59 +0,0 @@
---
title: Languages
description: Returns a collection of language objects for all sites, ordered by language weight.
categories: []
keywords: []
action:
related:
- methods/site/Language
returnType: langs.Languages
signatures: [SITE.Languages]
---
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:
```go-html-template
<pre>{{ jsonify (dict "indent" " ") .Site.Languages }}</pre>
```
With this site configuration:
{{< code-toggle file=hugo >}}
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = false
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Project Documentation'
weight = 2
{{< /code-toggle >}}
This template:
```go-html-template
<ul>
{{ range .Site.Languages }}
<li>{{ .Title }} ({{ .LanguageName }})</li>
{{ end }}
</ul>
```
Is rendered to:
```html
<ul>
<li>Projekt Dokumentation (Deutsch)</li>
<li>Project Documentation (English)</li>
</ul>
```

View File

@@ -1,21 +0,0 @@
---
title: LastChange
description: Returns the last modification date of site content.
categories: []
keywords: []
action:
related: []
returnType: time.Time
signatures: [SITE.LastChange]
---
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
```
[`time.Time`]: https://pkg.go.dev/time#Time
[functions]: /functions/time
[methods]: /methods/time

View File

@@ -1,55 +0,0 @@
---
title: MainSections
description: Returns a slice of the main section names as defined in the site configuration, falling back to the top level section with the most pages.
categories: []
keywords: []
action:
related: []
returnType: '[]string'
signatures: [SITE.MainSections]
---
Site configuration:
{{< code-toggle file=hugo >}}
[params]
mainSections = ['books','films']
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.MainSections }} → [books films]
```
If `params.mainSections` is not defined in the site configuration, this method returns a slice with one element---the top level section with the most pages.
With this content structure, the "films" section has the most pages:
```text
content/
├── books/
│ ├── book-1.md
│ └── book-2.md
├── films/
│ ├── film-1.md
│ ├── film-2.md
│ └── film-3.md
└── _index.md
```
Template:
```go-html-template
{{ .Site.MainSections }} → [films]
```
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:
```go-html-template
{{ range where .Site.RegularPages "Section" "in" .Site.MainSections }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -1,94 +0,0 @@
---
title: Menus
description: Returns a collection of menu objects for the given site.
categories: []
keywords: []
action:
related:
- methods/page/IsMenuCurrent
- methods/page/HasMenuCurrent
returnType: navigation.Menus
signatures: [SITE.Menus]
---
The `Menus` method on a `Site` object returns a collection of menus, where each menu contains one or more entries, either flat or nested. Each entry points to a page within the site, or to an external resource.
{{% note %}}
Menus can be defined and localized in several ways. Please see the [menus] section for a complete explanation and examples.
[menus]: /content-management/menus/
{{% /note %}}
A site can have multiple menus. For example, a main menu and a footer menu:
{{< code-toggle file=hugo >}}
[[menus.main]]
name = 'Home'
pageRef = '/'
weight = 10
[[menus.main]]
name = 'Books'
pageRef = '/books'
weight = 20
[[menus.main]]
name = 'Films'
pageRef = '/films'
weight = 30
[[menus.footer]]
name = 'Legal'
pageRef = '/legal'
weight = 10
[[menus.footer]]
name = 'Privacy'
pageRef = '/privacy'
weight = 20
{{< /code-toggle >}}
This template renders the main menu:
```go-html-template
{{ with site.Menus.main }}
<nav class="menu">
{{ range . }}
{{ if $.IsMenuCurrent .Menu . }}
<a class="active" aria-current="page" href="{{ .URL }}">{{ .Name }}</a>
{{ else }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
{{ end }}
</nav>
{{ end }}
```
When viewing the home page, the result is:
```html
<nav class="menu">
<a class="active" aria-current="page" href="/">Home</a>
<a href="/books/">Books</a>
<a href="/films/">Films</a>
</nav>
```
When viewing the "books" page, the result is:
```html
<nav class="menu">
<a href="/">Home</a>
<a class="active" aria-current="page" href="/books/">Books</a>
<a href="/films/">Films</a>
</nav>
```
You will typically render a menu using a partial template. As the active menu entry will be different on each page, use the [`partial`] function to call the template. Do not use the [`partialCached`] function.
The example above is simplistic. Please see the [menu templates] section for more information.
[menu templates]: /templates/menu-templates
[`partial`]: /functions/partials/include
[`partialCached`]: /functions/partials/includecached

View File

@@ -1,26 +0,0 @@
---
title: Pages
description: Returns a collection of all pages.
categories: []
keywords: []
action:
related:
- methods/site/AllPages
- methods/site/RegularPages
- methods/site/Sections
returnType: page.Pages
signatures: [SITE.Pages]
---
This method returns all page [kinds] in the current language. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: methods/site/regularpages
[kinds]: /getting-started/glossary/#page-kind
```go-html-template
{{ range .Site.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -1,29 +0,0 @@
---
title: Param
description: Returns the site parameter with the given key.
categories: []
keywords: []
action:
related: []
returnType: any
signatures: [SITE.Param KEY]
---
The `Param` method on a `Site` object is a convenience method to return the value of a user-defined parameter in the site configuration.
{{< code-toggle file=hugo >}}
[params]
display_toc = true
{{< /code-toggle >}}
```go-html-template
{{ .Site.Param "display_toc" }} → true
```
The above is equivalent to either of these:
```go-html-template
{{ .Site.Params.display_toc }}
{{ index .Site.Params "display_toc" }}
```

View File

@@ -1,47 +0,0 @@
---
title: Params
description: Returns a map of custom parameters as defined in the site configuration.
categories: []
keywords: []
action:
related:
- functions/collections/indexFunction
- methods/page/Params
- methods/page/Param
returnType: maps.Params
signatures: [SITE.Params]
---
With this site configuration:
{{< code-toggle file=hugo >}}
[params]
subtitle = 'The Best Widgets on Earth'
copyright-year = '2023'
[params.author]
email = 'jsmith@example.org'
name = 'John Smith'
[params.layouts]
rfc_1123 = 'Mon, 02 Jan 2006 15:04:05 MST'
rfc_3339 = '2006-01-02T15:04:05-07:00'
{{< /code-toggle >}}
Access the custom parameters by [chaining] the [identifiers]:
```go-html-template
{{ .Site.Params.subtitle }} → The Best Widgets on Earth
{{ .Site.Params.author.name }} → John Smith
{{ $layout := .Site.Params.layouts.rfc_1123 }}
{{ .Site.LastChange.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:
```go-html-template
{{ index .Site.Params "copyright-year" }} → 2023
```
[`index`]: /functions/collections/indexfunction
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -1,38 +0,0 @@
---
title: RegularPages
description: Returns a collection of all regular pages.
categories: []
keywords: []
action:
related:
- methods/site/AllPages
- methods/site/RegularPages
- methods/site/Sections
returnType: page.Pages
signatures: [SITE.RegularPages]
---
```go-html-template
{{ range .Site.RegularPages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
By default, Hugo sorts page collections by:
1. The page `weight` as defined in front matter
1. The page `date` as defined in front matter
1. The page `linkTitle` as defined in front matter
1. The file path
If the `linkTitle` is not defined, Hugo evaluates the `title` instead.
To change the sort order, use any of the `Pages` [sorting methods]. For example:
```go-html-template
{{ range .Site.RegularPages.ByTitle }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
```
[sorting methods]: /methods/pages/

View File

@@ -1,41 +0,0 @@
---
title: Sections
description: Returns a collection of first level section pages.
categories: []
keywords: []
action:
related:
- methods/site/AllPages
- methods/site/Pages
- methods/site/RegularPages
returnType: page.Pages
signatures: [SITE.Sections]
---
Given this content structure:
```text
content/
├── books/
│ ├── book-1.md
│ └── book-2.md
├── films/
│ ├── film-1.md
│ └── film-2.md
└── _index.md
```
This template:
```go-html-template
{{ range .Site.Sections }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
Is rendered to:
```html
<h2><a href="/books/">Books</a></h2>
<h2><a href="/films/">Films</a></h2>
```

View File

@@ -1,66 +0,0 @@
---
title: Sites
description: Returns a collection of all Site objects, one for each language, ordered by language weight.
categories: []
keywords: []
action:
related: []
returnType: page.Sites
signatures: [SITE.Sites]
---
With this site configuration:
{{< code-toggle file=hugo >}}
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = false
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
title = 'Project Documentation'
weight = 2
{{< /code-toggle >}}
This template:
```go-html-template
<ul>
{{ range .Site.Sites }}
<li><a href="{{ .Home.Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
```
Produces a list of links to each home page:
```html
<ul>
<li><a href="https://example.org/de/">Projekt Dokumentation</a></li>
<li><a href="https://example.org/en/">Project Documentation</a></li>
</ul>
```
To render a link to home page of the primary (first) language:
```go-html-template
{{ with .Site.Sites.First }}
<a href="{{ .Home.Permalink }}">{{ .Title }}</a>
{{ end }}
```
This is equivalent to:
```go-html-template
{{ with index .Site.Sites 0 }}
<a href="{{ .Home.Permalink }}">{{ .Title }}</a>
{{ end }}
```

View File

@@ -1,99 +0,0 @@
---
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.
categories: []
keywords: []
action:
related: []
returnType: page.TaxonomyList
signatures: [SITE.Taxonomies]
---
Conceptually, the `Taxonomies` method on a `Site` object returns a data structure such&nbsp;as:
{{< code-toggle >}}
taxonomy a:
- term 1:
- page 1
- page 2
- term 2:
- page 1
taxonomy b:
- term 1:
- page 2
- term 2:
- page 1
- page 2
{{< /code-toggle >}}
For example, on a book review site you might create two taxonomies; one for genres and another for authors.
With this site configuration:
{{< code-toggle file=hugo >}}
[taxonomies]
genre = 'genres'
author = 'authors'
{{< /code-toggle >}}
And this content structure:
```text
content/
├── books/
│ ├── and-then-there-were-none.md --> genres: suspense
│ ├── death-on-the-nile.md --> genres: suspense
│ └── jamaica-inn.md --> genres: suspense, romance
│ └── pride-and-prejudice.md --> genres: romance
└── _index.md
```
Conceptually, the taxonomies data structure looks like:
{{< code-toggle >}}
genres:
- suspense:
- And Then There Were None
- Death on the Nile
- Jamaica Inn
- romance:
- Jamaica Inn
- Pride and Prejudice
authors:
- achristie:
- And Then There Were None
- Death on the Nile
- ddmaurier:
- Jamaica Inn
- jausten:
- Pride and Prejudice
{{< /code-toggle >}}
To list the "suspense" books:
```go-html-template
<ul>
{{ range .Site.Taxonomies.genres.suspense }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
```
Hugo renders this to:
```html
<ul>
<li><a href="/books/and-then-there-were-none/">And Then There Were None</a></li>
<li><a href="/books/death-on-the-nile/">Death on the Nile</a></li>
<li><a href="/books/jamaica-inn/">Jamaica Inn</a></li>
</ul>
```
{{% note %}}
Hugo's taxonomy system is powerful, allowing you to classify content and create relationships between pages.
Please see the [taxonomies] section for a complete explanation and examples.
[taxonomies]: content-management/taxonomies/
{{% /note %}}

View File

@@ -1,22 +0,0 @@
---
title: Title
description: Returns the title as defined in the site configuration.
categories: []
keywords: []
action:
related: []
returnType: string
signatures: [SITE.Title]
---
Site configuration:
{{< code-toggle file=hugo >}}
title = 'My Documentation Site'
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.Title }} → My Documentation Site
```

View File

@@ -1,12 +0,0 @@
---
title: Site methods
linkTitle: Site
description: Use these methods with Site objects.
categories: []
keywords: []
menu:
docs:
parent: methods
---
Use these methods with Site objects. A multilingual project will have two or more sites, one for each language.