| 1 |
--- |
| 2 |
title: Truncated |
| 3 |
description: Reports whether the content length exceeds the summary length. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: bool |
| 9 |
signatures: [PAGE.Truncated] |
| 10 |
--- |
| 11 |
|
| 12 |
You can define a [summary][] manually, in front matter, or automatically. A manual summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary. |
| 13 |
|
| 14 |
The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for conditionally rendering a "read more" link: |
| 15 |
|
| 16 |
```go-html-template |
| 17 |
{{ range .Pages }} |
| 18 |
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2> |
| 19 |
{{ .Summary }} |
| 20 |
{{ if .Truncated }} |
| 21 |
<a href="{{ .RelPermalink }}">Read more...</a> |
| 22 |
{{ end }} |
| 23 |
{{ end }} |
| 24 |
``` |
| 25 |
|
| 26 |
> [!NOTE] |
| 27 |
> The `Truncated` method returns `false` if you define the summary in front matter. |
| 28 |
|
| 29 |
[summary]: /content-management/summaries/ |