Skip to content

Commit 4cfdfbe

Browse files
committed
content: Miscellaneous udpates for v0.157.0
1 parent 80dd7b0 commit 4cfdfbe

File tree

8 files changed

+225
-116
lines changed

8 files changed

+225
-116
lines changed

content/en/commands/hugo_gen_chromastyles.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Generate CSS stylesheet for the Chroma code highlighter
1111

1212
Generate CSS stylesheet for the Chroma code highlighter for a given style. This stylesheet is needed if markup.highlight.noClasses is disabled in config.
1313

14-
See https://xyproto.github.io/splash/docs/all.html for a preview of the available styles
14+
See https://gohugo.io/quick-reference/syntax-highlighting-styles/ for a preview of the available styles.
1515

1616
```
1717
hugo gen chromastyles [flags] [args]
@@ -26,7 +26,7 @@ hugo gen chromastyles [flags] [args]
2626
--lineNumbersTableStyle string foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"
2727
--omitClassComments omit CSS class comment prefixes in the generated CSS
2828
--omitEmpty omit empty CSS rules (deprecated, no longer needed)
29-
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly")
29+
--style string highlighter style (default "friendly")
3030
```
3131

3232
### Options inherited from parent commands

content/en/configuration/caches.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ images
2626
misc
2727
: Caches miscellaneous data.
2828

29+
modulegitinfo
30+
: Caches Git information for modules.
31+
2932
modulequeries
3033
: Caches the results of module resolution queries.
3134

content/en/configuration/imaging.md

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ categories: []
66
keywords: []
77
---
88

9-
## Processing options
10-
119
These are the default settings for processing images:
1210

13-
{{< code-toggle file=hugo >}}
14-
[imaging]
15-
anchor = 'Smart'
16-
bgColor = '#ffffff'
17-
compression = 'lossy'
18-
quality = 75
19-
resampleFilter = 'box'
20-
{{< /code-toggle >}}
11+
{{< code-toggle config=imaging />}}
12+
13+
## Top-level options
14+
15+
These global settings define how Hugo handles the fundamental aspects of image manipulation, such as cropping logic, background colors, and general output quality.
2116

2217
anchor
23-
: (`string`) The focal point used when cropping or filling an image. Valid options include `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. The `Smart` option utilizes the [`smartcrop.js`][] library to identify the most interesting area of the image. Default is `Smart`.
18+
: (`string`) The focal point used when cropping or filling an image. Valid case-insensitive options include `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`. The `Smart` option utilizes the [`smartcrop.js`][] library to identify the most interesting area of the image. Default is `smart`.
2419

2520
bgColor
2621
: (string) The background color used when converting transparent images to formats that do not support transparency, such as PNG to JPEG. This color also fills the empty space created when rotating an image by a non-orthogonal angle if the space is not transparent and a background color is not specified in the processing specification. The value must be an RGB [hexadecimal color][]. Default is `#ffffff`.
@@ -46,47 +41,9 @@ resampleFilter
4641

4742
Refer to the [source documentation][] for a complete list of available resampling filters. If you wish to improve image quality at the expense of performance, you may wish to experiment with the alternative filters.
4843

49-
## WebP images
50-
51-
{{< new-in 0.155.0 />}}
52-
53-
These are the default settings specific to processing WebP images:
54-
55-
{{< code-toggle file=hugo >}}
56-
[imaging.webp]
57-
hint = 'photo'
58-
method = 4
59-
useSharpYuv = true
60-
{{< /code-toggle >}}
61-
62-
hint
63-
: (`string`) The encoding preset used when processing WebP images, equivalent to the `-preset` flag for the [`cwebp`][] CLI. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. Default is `photo`.
64-
65-
Value|Example
66-
:--|:--
67-
`drawing`|Hand or line drawing with high-contrast details
68-
`icon`|Small colorful image
69-
`photo`|Outdoor photograph with natural lighting
70-
`picture`|Indoor photograph such as a portrait
71-
`text`|Image that is primarily text
72-
73-
method
74-
: (`int`) The effort level of the compression algorithm. Expressed as a whole number from `0` to `6`, inclusive, equivalent to the `-m` flag for the [`cwebp`][] CLI. Lower numbers prioritize processing speed, while higher numbers prioritize compression efficiency. Default is `4`.
75-
76-
useSharpYuv
77-
: (`bool`) The conversion method used for RGB-to-YUV encoding, equivalent to the `-sharp_yuv` flag for the [`cwebp`][] CLI. Enabling this prioritizes image sharpness at the expense of processing speed. Default is `true`.
78-
7944
## Exif method
8045

81-
These are the default settings for the [`Exif`] method on an image `Resource` object:
82-
83-
{{< code-toggle file=hugo >}}
84-
[imaging.exif]
85-
disableDate = false
86-
disableLatLong = false
87-
excludeFields = ""
88-
includeFields = ""
89-
{{< /code-toggle >}}
46+
The following parameters allow you to control how Hugo extracts and filters metadata when using the [`Exif`] method, helping you balance data granularity with build performance.
9047

9148
disableDate
9249
: (`bool`) Whether to disable the [`Date`][] method by returning its zero value. Default is `false`.
@@ -107,13 +64,7 @@ includeFields
10764

10865
{{< new-in 0.155.0 />}}
10966

110-
These are the default settings for the [`Meta`] method on an image `Resource` object:
111-
112-
{{< code-toggle file=hugo >}}
113-
[imaging.meta]
114-
fields = []
115-
sources = ['exif', 'iptc']
116-
{{< /code-toggle >}}
67+
The following parameters allow you to control how Hugo extracts and filters metadata when using the [`Meta`] method, helping you balance data granularity with build performance.
11768

11869
fields
11970
: (`[]string`) A [glob slice](g) matching the fields to include when extracting metadata. If empty, a default set excluding technical metadata is used. Set&nbsp;to&nbsp;`['**']`&nbsp;to include all fields.
@@ -124,6 +75,29 @@ fields
12475
sources
12576
: (`[]string`) The metadata sources to include, one or more of `exif`, `iptc`, or `xmp`. Default is `['exif', 'iptc']`. The XMP metadata is excluded by default to improve performance.
12677

78+
## WebP images
79+
80+
{{< new-in 0.155.0 />}}
81+
82+
These specialized settings provide granular control over the WebP encoding process, allowing you to optimize compression based on the specific visual characteristics of your imagery.
83+
84+
hint
85+
: (`string`) The encoding preset used when processing WebP images, equivalent to the `-preset` flag for the [`cwebp`][] CLI. Valid options include `drawing`, `icon`, `photo`, `picture`, or `text`. Default is `photo`.
86+
87+
Value|Example
88+
:--|:--
89+
`drawing`|Hand or line drawing with high-contrast details
90+
`icon`|Small colorful image
91+
`photo`|Outdoor photograph with natural lighting
92+
`picture`|Indoor photograph such as a portrait
93+
`text`|Image that is primarily text
94+
95+
method
96+
: (`int`) The effort level of the compression algorithm. Expressed as a whole number from `0` to `6`, inclusive, equivalent to the `-m` flag for the [`cwebp`][] CLI. Lower numbers prioritize processing speed, while higher numbers prioritize compression efficiency. Default is `2`.
97+
98+
useSharpYuv
99+
: (`bool`) The conversion method used for RGB-to-YUV encoding, equivalent to the `-sharp_yuv` flag for the [`cwebp`][] CLI. Enabling this prioritizes image sharpness at the expense of processing speed. Default is `false`.
100+
127101
[`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
128102
[`Exif`]: /methods/resource/exif/
129103
[`Meta`]: /methods/resource/meta/
Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: reflect.IsImageResource
3-
description: Reports whether the given value is a Resource object representing a processable image.
3+
description: Reports whether the given value is a Resource object representing an image as defined by its media type.
44
categories: []
55
keywords: []
66
params:
@@ -12,60 +12,16 @@ params:
1212

1313
{{< new-in 0.154.0 />}}
1414

15-
{{% glossary-term "processable image" %}}
15+
The following example demonstrates how to check if a resource is categorized as an image.
1616

17-
With this project structure:
18-
19-
```text
20-
project/
21-
├── assets/
22-
│ ├── a.json
23-
│ ├── b.avif
24-
│ └── c.jpg
25-
└── content/
26-
└── example/
27-
├── index.md
28-
├── d.json
29-
├── e.avif
30-
└── f.jpg
31-
```
32-
33-
These are the values returned by the `reflect.IsImageResource` function:
34-
35-
```go-html-template {file="layouts/page.html"}
36-
{{ with resources.Get "a.json" }}
37-
{{ reflect.IsImageResource . }} → false
38-
{{ end }}
39-
40-
{{ with resources.Get "b.avif" }}
41-
{{ reflect.IsImageResource . }} → false
42-
{{ end }}
43-
44-
{{ with resources.Get "c.jpg" }}
45-
{{ reflect.IsImageResource . }} → true
46-
{{ end }}
47-
```
48-
49-
In the example above, the `b.avif` image is not a processable image because Hugo can neither decode nor encode the AVIF image format.
50-
51-
```go-html-template {file="layouts/page.html"}
52-
{{ with .Resources.Get "d.json" }}
53-
{{ reflect.IsImageResource . }} → false
54-
{{ end }}
55-
56-
{{ with .Resources.Get "e.avif" }}
57-
{{ reflect.IsImageResource . }} → false
17+
```go-html-template
18+
{{ with resources.Get "image.jpg" }}
19+
{{ .MediaType.MainType }} → image
20+
{{ reflect.IsImageResource . }} → true
5821
{{ end }}
5922
60-
{{ with .Resources.Get "f.jpg" }}
61-
{{ reflect.IsImageResource . }} → true
62-
{{ end }}
63-
```
64-
65-
In the example above, the `e.avif` image is not a processable image because Hugo can neither decode nor encode the AVIF image format.
66-
67-
```go-html-template {file="layouts/page.html"}
68-
{{ with site.GetPage "/example" }}
69-
{{ reflect.IsImageResource . }} → false
23+
{{ with resources.Get "data.json" }}
24+
{{ .MediaType.MainType }} → application
25+
{{ reflect.IsImageResource . }} → false
7026
{{ end }}
7127
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: reflect.IsImageResourceProcessable
3+
description: Reports whether the given value is a Resource object representing a processable image.
4+
categories: []
5+
keywords: []
6+
params:
7+
functions_and_methods:
8+
aliases: []
9+
returnType: bool
10+
signatures: [reflect.IsImageResourceProcessable INPUT]
11+
---
12+
13+
{{< new-in 0.156.0 />}}
14+
15+
{{% glossary-term "processable image" %}}
16+
17+
## Usage example
18+
19+
The following example demonstrates how to check if a resource can be processed by Hugo's imaging pipeline using the `reflect.IsImageResourceProcessable` function.
20+
21+
```go-html-template
22+
{{ with resources.Get "image.jpg" }}
23+
{{ reflect.IsImageResourceProcessable . }} → true
24+
{{ end }}
25+
```
26+
27+
## Processable formats
28+
29+
The following table shows the result of `reflect.IsImageResourceProcessable` for various file types and their corresponding media types.
30+
31+
| Filename | Media Type | Processable |
32+
| :--- | :--- | :--- |
33+
| data.json | application/json | false |
34+
| image.avif | image/avif | false |
35+
| image.bmp | image/bmp | true |
36+
| image.gif | image/gif | true |
37+
| image.heic | image/heic | false |
38+
| image.heif | image/heif | false |
39+
| image.jpg | image/jpeg | true |
40+
| image.png | image/png | true |
41+
| image.svg | image/svg+xml | false |
42+
| image.tiff | image/tiff | true |
43+
| image.webp | image/webp | true |
44+
45+
## Metadata methods
46+
47+
Although AVIF, HEIC, and HEIF images are not processable, you can can determine their dimensions using the [`Width`] and [`Height`] methods.
48+
49+
```go-html-template
50+
{{ with resources.Get "image.avif" }}
51+
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
52+
{{ end }}
53+
```
54+
55+
[`Height`]: /methods/resource/height/
56+
[`Width`]: /methods/resource/width/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: reflect.IsImageResourceWithMeta
3+
description: Reports whether the given value is a Resource object representing an image with metadata.
4+
categories: []
5+
keywords: []
6+
params:
7+
functions_and_methods:
8+
aliases: []
9+
returnType: bool
10+
signatures: [reflect.IsImageResourceWithMeta INPUT]
11+
---
12+
13+
{{< new-in 0.156.0 />}}
14+
15+
An image with metadata is an image format from which Hugo can extract dimensions and, if present, Exif, IPTC, and XMP data.
16+
17+
## Usage example
18+
19+
The following example demonstrates how to check if a resource is an image format from which metadata can be extracted using the `reflect.IsImageResourceWithMeta` function.
20+
21+
```go-html-template
22+
{{ with resources.Get "image.avif" }}
23+
{{ reflect.IsImageResourceWithMeta . }} → true
24+
{{ end }}
25+
```
26+
27+
## Formats with metadata
28+
29+
The following table shows the result of `reflect.IsImageResourceWithMeta` for various file types and their corresponding media types.
30+
31+
| Filename | Media Type | With Meta |
32+
| :--- | :--- | :--- |
33+
| data.json | application/json | false |
34+
| image.avif | image/avif | true |
35+
| image.bmp | image/bmp | false |
36+
| image.gif | image/gif | false |
37+
| image.heic | image/heic | true |
38+
| image.heif | image/heif | true |
39+
| image.jpg | image/jpeg | true |
40+
| image.png | image/png | true |
41+
| image.svg | image/svg+xml | false |
42+
| image.tiff | image/tiff | true |
43+
| image.webp | image/webp | true |
44+
45+
## Metadata methods
46+
47+
If `reflect.IsImageResourceWithMeta` returns `true`, you can determine the image dimensions with the [`Width`][] and [`Height`][] methods, and access metadata with the [`Meta`][] method.
48+
49+
```go-html-template
50+
{{ with resources.Get "image.avif" }}
51+
{{ if reflect.IsImageResourceWithMeta . }}
52+
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
53+
{{ with .Meta }}
54+
<p>Taken on: {{ .Date }}</p>
55+
{{ end }}
56+
{{ end }}
57+
{{ end }}
58+
```
59+
60+
[`Height`]: /methods/resource/height/
61+
[`Meta`]: /methods/resource/meta/
62+
[`Width`]: /methods/resource/width/

content/en/quick-reference/glossary/processable-image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: processable image
44

55
A _processable image_ is an image file characterized by one of the following [_media types_](g):
66

7+
- `image/bmp`
78
- `image/gif`
89
- `image/jpeg`
910
- `image/png`

0 commit comments

Comments
 (0)