From 07c2400d832a6485eaf4dbb6def11ab8195fb4a5 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Thu, 5 Sep 2024 10:05:21 -0700 Subject: [PATCH] Document alternative to Summary method --- content/en/content-management/summaries.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/content/en/content-management/summaries.md b/content/en/content-management/summaries.md index 174495a0c..678666e1a 100644 --- a/content/en/content-management/summaries.md +++ b/content/en/content-management/summaries.md @@ -111,3 +111,18 @@ Render the summary in a template by calling the [`Summary`] method on a `Page` o {{ end }} ``` + +## Alternative + +Instead of calling the `Summary` method on a `Page` object, use the [`strings.Truncate`] function for granular control of the summary length. For example: + +[`strings.Truncate`]: /functions/strings/truncate/ + +```go-html-template +{{ range site.RegularPages }} +

{{ .LinkTitle }}

+
+ {{ .Content | strings.Truncate 42 }} +
+{{ end }} +```