summaryrefslogtreecommitdiffstats
path: root/docs/content/en/content-management/related.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/content-management/related.md')
-rw-r--r--docs/content/en/content-management/related.md29
1 files changed, 15 insertions, 14 deletions
diff --git a/docs/content/en/content-management/related.md b/docs/content/en/content-management/related.md
index 9ede15252..2d2077c81 100644
--- a/docs/content/en/content-management/related.md
+++ b/docs/content/en/content-management/related.md
@@ -1,25 +1,22 @@
---
title: Related Content
+linkTitle: Related Content
description: List related content in "See Also" sections.
-date: 2017-09-05
categories: [content management]
keywords: [content]
menu:
docs:
- parent: "content-management"
- weight: 40
-weight: 30
-draft: false
-aliases: [/content/related/,/related/]
+ parent: content-management
+ weight: 110
toc: true
+weight: 110
+aliases: [/content/related/,/related/]
---
-
Hugo uses a set of factors to identify a page's related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo's default [Related Content configuration](#configure-related-content).
## List Related Content
-
To list up to 5 related pages (which share the same _date_ or _keyword_ parameters) is as simple as including something similar to this partial in your single page template:
{{< code file="layouts/partials/related.html" >}}
@@ -27,9 +24,9 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete
{{ with $related }}
<h3>See Also</h3>
<ul>
- {{ range . }}
- <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
- {{ end }}
+ {{ range . }}
+ <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+ {{ end }}
</ul>
{{ end }}
{{< /code >}}
@@ -39,25 +36,28 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete
Here is the list of "Related" methods available on a page collection such `.RegularPages`.
#### .Related PAGE
+
Returns a collection of pages related the given one.
-```
+```go-html-template
{{ $related := site.RegularPages.Related . }}
```
#### .RelatedIndices PAGE INDICE1 [INDICE2 ...]
+
Returns a collection of pages related to a given one restricted to a list of indices.
-```
+```go-html-template
{{ $related := site.RegularPages.RelatedIndices . "tags" "date" }}
```
#### .RelatedTo KEYVALS [KEYVALS2 ...]
+
Returns a collection of pages related together by a set of indices and their match.
In order to build those set and pass them as argument, one must use the `keyVals` function where the first argument would be the `indice` and the consecutive ones its potential `matches`.
-```
+```go-html-template
{{ $related := site.RegularPages.RelatedTo ( keyVals "tags" "hugo" "rocks") ( keyVals "date" .Date ) }}
```
@@ -66,6 +66,7 @@ Read [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-r
{{% /note %}}
## Configure Related Content
+
Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed.
### Default configuration