Skip to content

Commit

Permalink
all: Updates required for v0.123.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Jan 31, 2024
1 parent 33d8c10 commit 9117f1d
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 71 deletions.
20 changes: 10 additions & 10 deletions content/en/content-management/page-bundles.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ A Page Bundle can be one of:
- Leaf Bundle (leaf means it has no children)
- Branch Bundle (home page, section, taxonomy terms, taxonomy list)

| | Leaf Bundle | Branch Bundle |
|-------------------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) |
| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Allowed Resources | Page and non-page (like images, PDF, etc.) types | Only non-page (like images, PDF, etc.) types |
| Where can the Resources live? | At any directory level within the leaf bundle directory. | Only in the directory level **of** the branch bundle directory i.e. the directory containing the `_index.md` ([ref](https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi)). |
| Layout type | [`single`](/templates/single-page-templates/) | [`list`](/templates/lists) |
| Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it |
| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` |
| Content from non-index page files...| Accessed only as page resources | Accessed only as regular pages |
| | Leaf Bundle | Branch Bundle |
|-------------------------------------|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| Usage | Collection of content and attachments for single pages | Collection of attachments for section pages (home page, section, taxonomy terms, taxonomy list) |
| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] |
| Allowed Resources | Page and non-page (like images, PDF, etc.) types | Only non-page (like images, PDF, etc.) types |
| Where can the Resources live? | At any directory level within the leaf bundle directory. | At any directory level within the branch bundle directory. |
| Layout type | [`single`](/templates/single-page-templates/) | [`list`](/templates/lists) |
| Nesting | Does not allow nesting of more bundles under it | Allows nesting of leaf or branch bundles under it |
| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` |
| Content from non-index page files...| Accessed only as page resources | Accessed only as regular pages |

## Leaf bundles

Expand Down
12 changes: 12 additions & 0 deletions content/en/functions/data/GetCSV.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ action:
toc: true
---

{{% deprecated-in 0.123.0 %}}
Instead, use [`transform.Unmarshal`] with a [global], [page], or [remote] resource.

See the [remote data example].

[`transform.Unmarshal`]: /functions/transform/unmarshal/
[global]: /getting-started/glossary/#global-resource
[page]: /getting-started/glossary/#page-resource
[remote data example]: /functions/resources/getremote/#remote-data
[remote]: /getting-started/glossary/#remote-resource
{{% /deprecated-in %}}

Given the following directory structure:

```text
Expand Down
12 changes: 12 additions & 0 deletions content/en/functions/data/GetJSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ action:
toc: true
---

{{% deprecated-in 0.123.0 %}}
Instead, use [`transform.Unmarshal`] with a [global], [page], or [remote] resource.

See the [remote data example].

[`transform.Unmarshal`]: /functions/transform/unmarshal/
[global]: /getting-started/glossary/#global-resource
[page]: /getting-started/glossary/#page-resource
[remote data example]: /functions/resources/getremote/#remote-data
[remote]: /getting-started/glossary/#remote-resource
{{% /deprecated-in %}}

Given the following directory structure:

```text
Expand Down
1 change: 1 addition & 0 deletions content/en/functions/fmt/Errorf.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ action:
related:
- functions/fmt/Erroridf
- functions/fmt/Warnf
- functions/fmt/Warnidf
returnType: string
signatures: ['fmt.Errorf FORMAT [INPUT]']
aliases: [/functions/errorf]
Expand Down
7 changes: 4 additions & 3 deletions content/en/functions/fmt/Erroridf.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ action:
related:
- functions/fmt/Errorf
- functions/fmt/Warnf
- functions/fmt/Warnidf
returnType: string
signatures: ['fmt.Erroridf ID FORMAT [INPUT]']
aliases: [/functions/erroridf]
---

{{% include "functions/fmt/_common/fmt-layout.md" %}}

The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration.
The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreLogs` array in your site configuration.

This template code:

Expand All @@ -28,13 +29,13 @@ Produces this console log:
```text
ERROR You should consider fixing this.
You can suppress this error by adding the following to your site configuration:
ignoreErrors = ['error-42']
ignoreLogs = ['error-42']
```

To suppress this message:

{{< code-toggle file=hugo >}}
ignoreErrors = ["error-42"]
ignoreLogs = ["error-42"]
{{< /code-toggle >}}

[`errorf`]: /functions/fmt/errorf
1 change: 1 addition & 0 deletions content/en/functions/fmt/Warnf.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ action:
related:
- functions/fmt/Errorf
- functions/fmt/Erroridf
- functions/fmt/Warnidf
returnType: string
signatures: ['fmt.Warnf FORMAT [INPUT]']
aliases: [/functions/warnf]
Expand Down
43 changes: 43 additions & 0 deletions content/en/functions/fmt/Warnidf.md
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
2 changes: 1 addition & 1 deletion content/en/methods/page/BundleType.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ categories: []
keywords: []
action:
related: []
returnType: files.ContentClass
returnType: string
signatures: [PAGE.BundleType]
---

Expand Down
8 changes: 7 additions & 1 deletion content/en/methods/site/LastChange.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ 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
```

Expand Down
23 changes: 23 additions & 0 deletions content/en/methods/site/Lastmod.md
Original file line number Diff line number Diff line change
@@ -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" }} → October 16, 2023
```

[`time.Time`]: https://pkg.go.dev/time#Time
[functions]: /functions/time
[methods]: /methods/time
2 changes: 1 addition & 1 deletion content/en/methods/site/Sites.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
60 changes: 38 additions & 22 deletions content/en/templates/output-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Given a media type and some additional configuration, you get an **Output Format

This is the full set of Hugo's built-in output formats:

{{< datatable "config" "outputFormats" "name" "mediaType" "path" "baseName" "rel" "protocol" "isPlainText" "isHTML" "noUgly" "permalinkable" >}}
{{< datatable "config" "outputFormats" "name" "baseName" "isHTML" "isPlainText" "mediaType" "noUgly" "path" "permalinkable" "protocol" "rel" >}}

- A page can be output in as many output formats as you want, and you can have an infinite amount of output formats defined **as long as they resolve to a unique path on the file system**. In the above table, the best example of this is `amp` vs. `html`. `amp` has the value `amp` for `path` so it doesn't overwrite the `html` version; e.g. we can now have both `/index.html` and `/amp/index.html`.
- The `mediaType` must match a defined media type.
Expand All @@ -83,40 +83,56 @@ The above example is fictional, but if used for the homepage on a site with `bas

### Configure output formats

The following is the full list of configuration options for output formats and their default values:
Use these parameters when configuring an output format:

mediaType
: this must match the `Type` of a defined media type.
baseName
: (`string`) The base name of the published file. Default is `index`.

path
: sub path to save the output files.
isHTML
: (`bool`) If `true`, classifies the output format as HTML. Hugo uses this value to determine when to create alias redirects, when to inject the LiveReload script, etc. Default is `false`.

baseName
: the base file name for the list file names (homepage, etc.). **Default:** `index`.
isPlainText
: (`bool`) If `true`, Hugo parses templates for this output format with Go's [text/template] package instead of the [html/template] package. Default is `false`.

rel
: can be used to create `rel` values in `link` tags. **Default:** `alternate`.
[html/template]: https://pkg.go.dev/html/template
[text/template]: https://pkg.go.dev/text/template

protocol
: will replace the "http://" or "https://" in your `baseURL` for this output format.
mediaType
: (`string`) The [media type] of the published file. This must match a defined media type, either [built-in](#media-types) or custom.

isPlainText
: use Go's plain text templates parser for the templates. **Default:** `false`.
[media type]: https://en.wikipedia.org/wiki/Media_type

isHTML
: used in situations only relevant for `HTML`-type formats; e.g., page aliases. **Default:** `false`.
notAlternative
: (`bool`) If `true`, excludes this output format from the values returned by the [`AlternativeOutputFormats`] method on a `Page` object. Default is `false`.

[`AlternativeOutputFormats`]: /methods/page/alternativeoutputformats/

noUgly
: used to turn off ugly URLs If `uglyURLs` is set to `true` in your site. **Default:** `false`.
: (`bool`) If `true`, disables ugly URLs for this output format when `uglyURLs` is `true` in your site configuration. Default is `false`.

notAlternative
: enable if it doesn't make sense to include this format in an `AlternativeOutputFormats` format listing on `Page` (e.g., with `CSS`). Note that we use the term _alternative_ and not _alternate_ here, as it does not necessarily replace the other format. **Default:** `false`.
path
: (`string`) The path to the directory containing the published files, relative to the root of the publish directory.

permalinkable
: make `.Permalink` and `.RelPermalink` return the rendering Output Format rather than main ([see below](#link-to-output-formats)). This is enabled by default for `HTML` and `AMP`. **Default:** `false`.
: (`bool`) If `true`, the [`Permalink`] and [`RelPermalink`] methods on a `Page` object return the rendering output format rather than main ouptut format ([see below](#link-to-output-formats)). Enabled by default for the `html` and `amp` output formats. Default is `false`.

[`Permalink`]: /methods/page/permalink/
[`RelPermalink`]: /methods/page/relpermalink/

protocol
: (`string`) The protocol (scheme) of the URL for this output format. For example, `https://` or `webcal://`. Default is the scheme of the `baseURL` parameter in your site configuration, typically `https://`.

rel
: (`string`) If provided, you can assign this value to `rel` attributes in `link` elements when iterating over ouput formats in your templates. Default is `alternate`.

root
: (`bool`) If `true`, files will be published to the root of the publish directory. Default is `false`.

ugly
: (`bool`) If `true`, enables uglyURLs for this output format when `uglyURLs` is `false` in your site configuration. Default is `false`.

weight
: Setting this to a non-zero value will be used as the first sort criteria.
: (`int`) When set to a non-zero value, Hugo uses the `weight` as the first criteria when sorting output formats, falling back to the name of the output format. Lighter items float to the top, while heavier items sink to the bottom. Hugo renders output formats sequentially based on the sort order.

## Output formats for pages

Expand Down Expand Up @@ -172,7 +188,7 @@ Each `Page` has both an `.OutputFormats` (all formats, including the current) an

## Link to output formats

`.Permalink` and `.RelPermalink` on `Page` will return the first output format defined for that page (usually `HTML` if nothing else is defined). This is regardless of the template file they are being called from.
The `Permalink` and `RelPermalink` methods on a `Page` object return the first output format defined for that page (usually `HTML` if nothing else is defined). This is regardless of the template from which they are called.

__from `single.json.json`:__
```go-html-template
Expand Down
11 changes: 0 additions & 11 deletions content/en/troubleshooting/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ In the content/_index.md file:

If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`.

###### Why is a given section not published?

In the content/section/_index.md file:

- Is `draft` set to `true`?
- Is the `date` in the future?
- Is the `publishDate` in the future?
- Is the `expiryDate` in the past?

If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`.

###### Why is a given page not published?

In the content/section/page.md file, or in the content/section/page/index.md file:
Expand Down
Loading

0 comments on commit 9117f1d

Please sign in to comment.