mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 23:38:53 +00:00
content: Add warning about automatic summaries
See https://github.com/gohugoio/hugo/issues/14044
This commit is contained in:
committed by
GitHub
parent
2065fadded
commit
ca21f5fbd3
@@ -79,6 +79,9 @@ For example, with a `summaryLength` of 7, the automatic summary will be:
|
||||
<p>This is the second paragraph.</p>
|
||||
```
|
||||
|
||||
> [!warning]
|
||||
> 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.
|
||||
|
||||
## Comparison
|
||||
|
||||
Each summary type has different characteristics:
|
||||
@@ -121,3 +124,5 @@ Instead of calling the `Summary` method on a `Page` object, use the [`strings.Tr
|
||||
</div>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
[#14044]: https://github.com/gohugoio/hugo/issues/14044
|
||||
|
||||
@@ -25,6 +25,9 @@ To list the pages in a section with a summary beneath each link:
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
> [!warning]
|
||||
> 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.
|
||||
|
||||
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:
|
||||
|
||||
```go-html-template
|
||||
@@ -42,3 +45,4 @@ Depending on content length and how you define the summary, the summary may be e
|
||||
|
||||
[`Truncated`]: /methods/page/truncated
|
||||
[summary]: /content-management/summaries/
|
||||
[automatic summary]: /content-management/summaries/#automatic-summary
|
||||
|
||||
Reference in New Issue
Block a user