Skip to content

Commit ca21f5f

Browse files
authored
content: Add warning about automatic summaries
See gohugoio/hugo#14044
1 parent 2065fad commit ca21f5f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

‎content/en/content-management/summaries.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ For example, with a `summaryLength` of 7, the automatic summary will be:
7979
<p>This is the second paragraph.</p>
8080
```
8181

82+
> [!warning]
83+
> Automatic `.Summary` may cut block tags (e.g., `blockquote`) in the middle when `summaryLength` is reached, causing the browser to recover the end tag (the end tag will be inserted before the parent's end tag), resulting in unexpected rendering behavior. To avoid this, wrap `.Summary` in a `<div>`; alternatively, wrap it together with the heading tag using `<section>`. You can avoid this entirely by using a manual summary. See issue [#14044] for details.
84+
8285
## Comparison
8386

8487
Each summary type has different characteristics:
@@ -121,3 +124,5 @@ Instead of calling the `Summary` method on a `Page` object, use the [`strings.Tr
121124
</div>
122125
{{ end }}
123126
```
127+
128+
[#14044]: https://github.com/gohugoio/hugo/issues/14044

‎content/en/methods/page/Summary.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ To list the pages in a section with a summary beneath each link:
2525
{{ end }}
2626
```
2727

28+
> [!warning]
29+
> Automatic `.Summary` may cut block tags (e.g., `blockquote`) in the middle, causing the browser to recover the end tag. See [automatic summary] for details and for ways to avoid this.
30+
2831
Depending on content length and how you define the summary, the summary may be equivalent to the content itself. To determine whether the content length exceeds the summary length, use the [`Truncated`] method on a `Page` object. This is useful for conditionally rendering a “read more” link:
2932

3033
```go-html-template
@@ -42,3 +45,4 @@ Depending on content length and how you define the summary, the summary may be e
4245
4346
[`Truncated`]: /methods/page/truncated
4447
[summary]: /content-management/summaries/
48+
[automatic summary]: /content-management/summaries/#automatic-summary

0 commit comments

Comments
 (0)