Dear all,
version used: Hugo Static Site Generator v0.50/extended darwin/amd64 BuildDate: unknown
Following this example in the docs I’m trying to render content from a headless bundle on my homepage (template index.html).
This is my file structure:
|- headless
|- index.md
|- test.md
This is my frontmatter from index.md:
+++
title = "Index headless"
description = ""
headline = ""
img = ""
c2a = ""
type = ""
date = 2019-02-21T23:02:14+01:00
weight = ""
draft = true
headless = true
+++
In my index.html template I start with this logic:
{{ $headless := .Site.GetPage "/headless" }}
{{ with $headless }}<script>console.log({{ $headless }})</script>{{ end }}
This is my console.log:
So far ist looks good, the array of page resources is present. But when I add
{{ $reusablePages := $headless.Resources.ByType "page" }}
things break and I get the following error:
Rebuild failed:
Failed to render pages: "/Users/myname/myrootdir/layouts/index.html:4:30": execute of template failed: template: index.html:4:30: executing "main" at <$headless.Resources....>: can't evaluate field Resources in type *hugolib.Page
I’ve tried several other options such as using .Resources.Match (as in the example) but no matter what I try, the error remains. I pretty much have no idea what’s going wrong and would appreciate any help!
This is the complete offending code:
{{ $headless := .Site.GetPage "/headless" }}
{{ $reusablePages := $headless.Resources.ByType "page" }}
{{ with $headless }}<script>console.log({{ $headless }})</script>{{ end }}