Skip to content

Commit d053fa1

Browse files
authored
Update to reflect changes in v0.134.1
1 parent 137dc32 commit d053fa1

File tree

4 files changed

+52
-43
lines changed

4 files changed

+52
-43
lines changed

‎content/en/content-management/summaries.md‎

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,77 +17,73 @@ aliases: [/content/summaries/,/content-management/content-summaries/]
1717
<!-- If you do, you will break its first literal usage on this page. -->
1818
<!--more-->
1919

20-
You can define a content summary manually, in front matter, or automatically. A manual content summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.
20+
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.
2121

2222
Review the [comparison table](#comparison) below to understand the characteristics of each summary type.
2323

2424
## Manual summary
2525

26-
Use a `<!--more-->` divider to indicate the end of the content summary. Hugo will not render the summary divider itself.
26+
Use a `<!--more-->` divider to indicate the end of the summary. Hugo will not render the summary divider itself.
2727

28-
{{< code file=content/sample.md >}}
28+
{{< code file=content/example.md >}}
2929
+++
3030
title: 'Example'
3131
date: 2024-05-26T09:10:33-07:00
3232
+++
3333

34-
Thénardier was not mistaken. The man was sitting there, and letting
35-
Cosette get somewhat rested.
34+
This is the first paragraph.
3635

3736
<!--more-->
3837

39-
The inn-keeper walked round the brushwood and presented himself
40-
abruptly to the eyes of those whom he was in search of.
38+
This is the second paragraph.
4139
{{< /code >}}
4240

43-
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the content summary.
41+
When using the Emacs Org Mode [content format], use a `# more` divider to indicate the end of the summary.
4442

4543
[content format]: /content-management/formats/
4644

4745
## Front matter summary
4846

4947
Use front matter to define a summary independent of content.
5048

51-
{{< code file=content/sample.md >}}
49+
{{< code file=content/example.md >}}
5250
+++
5351
title: 'Example'
5452
date: 2024-05-26T09:10:33-07:00
55-
summary: 'Learn more about _Les Misérables_ by Victor Hugo.'
53+
summary: 'This summary is independent of the content.'
5654
+++
5755

58-
Thénardier was not mistaken. The man was sitting there, and letting
59-
Cosette get somewhat rested. The inn-keeper walked round the
60-
brushwood and presented himself abruptly to the eyes of those whom
61-
he was in search of.
56+
This is the first paragraph.
57+
58+
This is the second paragraph.
6259
{{< /code >}}
6360

6461
## Automatic summary
6562

66-
If you have not defined the summary manually or in front matter, Hugo automatically defines the summary based on the [`summaryLength`] in your site configuration.
63+
If you do not define the summary manually or in front matter, Hugo automatically defines the summary based on the [`summaryLength`] in your site configuration.
6764

6865
[`summaryLength`]: /getting-started/configuration/#summarylength
6966

70-
{{< code file=content/sample.md >}}
67+
{{< code file=content/example.md >}}
7168
+++
7269
title: 'Example'
7370
date: 2024-05-26T09:10:33-07:00
7471
+++
7572

76-
Thénardier was not mistaken. The man was sitting there, and letting
77-
Cosette get somewhat rested. The inn-keeper walked round the
78-
brushwood and presented himself abruptly to the eyes of those whom
79-
he was in search of.
73+
This is the first paragraph.
74+
75+
This is the second paragraph.
76+
77+
This is the third paragraph.
8078
{{< /code >}}
8179

82-
For example, with a `summaryLength` of 10, the automatic summary will be:
80+
For example, with a `summaryLength` of 7, the automatic summary will be:
8381

84-
```text
85-
Thénardier was not mistaken. The man was sitting there, and letting
86-
Cosette get somewhat rested.
82+
```html
83+
<p>This is the first paragraph.</p>
84+
<p>This is the second paragraph.</p>
8785
```
8886

89-
Note that the `summaryLength` is an approximate number of words.
90-
9187
## Comparison
9288

9389
Each summary type has different characteristics:

‎content/en/getting-started/configuration.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ Default [sitemap configuration](/templates/sitemap/#configuration).
446446

447447
###### summaryLength
448448

449-
(`int`) Applicable to automatic summaries, the approximate number of words to render when calling the [`Summary`] method on a `Page` object. Default is `70`.
449+
(`int`) Applicable to [automatic summaries], the minimum number of words to render when calling the [`Summary`] method on a `Page` object. In this case the `Summary` method returns the content, truncated to the paragraph closest to the `summaryLength`.
450450

451+
[automatic summaries]: /content-management/summaries/#automatic-summary
451452
[`Summary`]: /methods/page/summary/
452453

453454
###### taxonomies

‎content/en/methods/page/Summary.md‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
title: Summary
3-
description: Returns the content summary of the given page.
3+
description: Returns the summary of the given page.
44
categories: []
55
keywords: []
66
action:
77
related:
88
- methods/page/Truncated
9+
- methods/page/Content
10+
- methods/page/ContentWithoutSummary
911
- methods/page/Description
1012
returnType: template.HTML
1113
signatures: [PAGE.Summary]
@@ -15,11 +17,9 @@ action:
1517
<!-- If you do, you will break its first literal usage on this page. -->
1618
<!--more-->
1719

18-
There are three ways to define the [content summary]:
20+
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.
1921

20-
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.
21-
2. Manually split the content with a `<!--more-->` tag in Markdown. Everything before the tag is included in the summary.
22-
3. Create a `summary` field in front matter.
22+
[summary]: /content-management/summaries/
2323

2424
To list the pages in a section with a summary beneath each link:
2525

@@ -30,4 +30,20 @@ To list the pages in a section with a summary beneath each link:
3030
{{ end }}
3131
```
3232

33-
[content summary]: /content-management/summaries/
33+
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:
34+
35+
[`Truncated`]: /methods/page/truncated
36+
37+
```go-html-template
38+
{{ range .Pages }}
39+
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
40+
{{ .Summary }}
41+
{{ if .Truncated }}
42+
<a href="{{ .RelPermalink }}">Read more...</a>
43+
{{ end }}
44+
{{ end }}
45+
```
46+
47+
{{% note %}}
48+
The `Truncated` method returns `false` if you define the summary in front matter.
49+
{{% /note %}}

‎content/en/methods/page/Truncated.md‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@ action:
1010
signatures: [PAGE.Truncated]
1111
---
1212

13-
There are three ways to define the [content summary]:
13+
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.
1414

15-
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.
16-
2. Manually split the content with a `<--more-->` tag in Markdown. Everything before the tag is included in the summary.
17-
3. Create a `summary` field in front matter.
15+
[summary]: /content-management/summaries/
1816

19-
{{% note %}}
20-
The `Truncated` method returns `false` if you define the summary in front matter.
21-
{{% /note %}}
22-
23-
The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for rendering a "read more" link:
17+
The `Truncated` method returns `true` if the content length exceeds the summary length. This is useful for conditionally rendering a "read more" link:
2418

2519
```go-html-template
2620
{{ range .Pages }}
@@ -32,4 +26,6 @@ The `Truncated` method returns `true` if the content length exceeds the summary
3226
{{ end }}
3327
```
3428

35-
[content summary]: /content-management/summaries/
29+
{{% note %}}
30+
The `Truncated` method returns `false` if you define the summary in front matter.
31+
{{% /note %}}

0 commit comments

Comments
 (0)