Skip to content

Commit 8418e8f

Browse files
committed
content: add block tag leakage warning for automatic .Summary
Read more gohugoio/hugo#14044
1 parent a0784f2 commit 8418e8f

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)