Hi! I’m trying to create a Related Content section in a page using .Site.RegularPages.Related as shown in the docs, but it gives me the following error, saying something about “keywords” index not being supported (?)
Start building sites …
ERROR 2021/11/19 17:09:24 render of "page" failed: "....../themes/basic/layouts/posts/single.html:32:32": execute of template failed: template: posts/single.html:32:32: executing "main" at <.Site.RegularPages.Related>: error calling Related: indexing currently not supported for index "keywords" and type []interface {}
Built in 158 ms
Error: Error building site: failed to render pages: render of "page" failed: "....../themes/basic/layouts/posts/single.html:32:32": execute of template failed: template: posts/single.html:32:32: executing "main" at <.Site.RegularPages.Related>: error calling Related: indexing currently not supported for index "keywords" and type []interface {}
I’m following the indication in the docs, like this:
<section class="related">
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
<h3>Related pages</h3>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
</section>
And adding the “keywords” param in the front matter, like this:
keywords:
- keywordA
- keywordB
If it’s any useful to know I’m following the book “Build websites with HUGO”, by Brian P. Hogan
I already tried specifying the related content config in the config.toml file or even using a more “manual” approach, like this:
{{ $related := .Site.RegularPages.RelatedIndices . "keywords" | first 5 }}
… but it didn’t worked either.
Any ideas? I’ll gladly share any other relevant information about this. Thanks in advance!
Project repo: GitHub - dredstrauss/dev-portfolio-hugo: Learning project using HUGO framework