From ca21f5fbd3dc3f93b716809a310ba2807a74cdd2 Mon Sep 17 00:00:00 2001 From: Sardorbek Imomaliev <3041675+imomaliev@users.noreply.github.com> Date: Mon, 13 Oct 2025 21:00:41 +0100 Subject: [PATCH] content: Add warning about automatic summaries See https://github.com/gohugoio/hugo/issues/14044 --- content/en/content-management/summaries.md | 5 +++++ content/en/methods/page/Summary.md | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/content/en/content-management/summaries.md b/content/en/content-management/summaries.md index da61c2c8e..d665a55a5 100644 --- a/content/en/content-management/summaries.md +++ b/content/en/content-management/summaries.md @@ -79,6 +79,9 @@ For example, with a `summaryLength` of 7, the automatic summary will be:

This is the second paragraph.

``` +> [!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 `
`; alternatively, wrap it together with the heading tag using `
`. 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
{{ end }} ``` + +[#14044]: https://github.com/gohugoio/hugo/issues/14044 diff --git a/content/en/methods/page/Summary.md b/content/en/methods/page/Summary.md index 9158e571d..c72a2440d 100644 --- a/content/en/methods/page/Summary.md +++ b/content/en/methods/page/Summary.md @@ -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