content/partials/index.md:
---
draft: false
headless: true
resources:
- name: footer
src: site-footer.md
---
If I do this in my baseof.html:
{{ $partials := .Site.GetPage "partials" }}
{{ with $partials }}<script>console.log({{ $partials }})</script>{{ end }}
I can see in the browser console that the object does not contain a Resources array. I was pretty confused about why I was unable to GetMatch that footer before I found this nice way of outputting the object in the forums.
Why might this be?
site-footer.md lives alongside index.md in content/partials.
bep
August 7, 2020, 7:54pm
2
I doubt that sending converting $partials to JSON will include the .Resources
.
Oh… How might I inspect the object in its totality, then?
Doing
{{ printf "%#v" $partials }}
gives
&hugolib.pageState{pageOutputs:[]*hugolib.pageOutput{(*hugolib.pageOutput)(0xc0006cc7e0), (*hugolib.pageOutput)(0xc0006cc900)}, pageOutput:(*hugolib.pageOutput)(0xc0006cc7e0), pageCommon:(*hugolib.pageCommon)(0xc00043d400)}
Doing
{{ $partials | debug.Dump }}
gives
&hugolib.pageState{}
Doing
{{ $footer := $partials.Resources.GetMatch "footer" }}
{{ printf "%#v" $footer }}
gives
<nil>
I haven’t found any informative way to debug
Ok, now I figured it out by using the console.logging against
{{ $reusablePages := $partials.Resources.Match "*" }}
To my horror I discovered that it had
Name: "site-footer.md"
As expected, I was now able to get it by
{{ $footer := $partials.Resources.GetMatch "site-footer.md" }}
Is this a bug? The docs clearly state for an example :
sunset.jpg
will receive a new Name
and can now be found with .GetMatch "header"
Why did it not pick up my name definition from index.md, but stuck with the file name instead?
Edit: I am using 0.74.3 from Arch Linux AUR.