summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/page/Truncated.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/methods/page/Truncated.md')
-rw-r--r--docs/content/en/methods/page/Truncated.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/content/en/methods/page/Truncated.md b/docs/content/en/methods/page/Truncated.md
new file mode 100644
index 000000000..e6051f0cd
--- /dev/null
+++ b/docs/content/en/methods/page/Truncated.md
@@ -0,0 +1,35 @@
+---
+title: Truncated
+description: Reports whether the content length exceeds the summary length.
+categories: []
+keywords: []
+action:
+ related:
+ - methods/page/Summary
+ returnType: bool
+ signatures: [PAGE.Truncated]
+---
+
+There are three ways to define the [content summary]:
+
+1. Let Hugo create the summary based on the first 70 words. You can change the number of words by setting the `summaryLength` in your site configuration.
+2. Manually split the content with a `<--more-->` tag in markdown. Everything before the tag is included in the summary.
+3. Create a `summary` field in front matter.
+
+{{% note %}}
+The `Truncated` method returns `false` if you define the summary in front matter.
+{{% /note %}}
+
+The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for rendering a "read more" link:
+
+```go-html-template
+{{ range .Pages }}
+ <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+ {{ .Summary }}
+ {{ if .Truncated }}
+ <a href="{{ .RelPermalink }}">Read more...</a>
+ {{ end }}
+{{ end }}
+```
+
+[content summary]: /content-management/summaries