Page Resources for non-page

Is it possible to use page resources for a non-page/non-section partial?

Let me elaborate.

In contents, I’d like to create menu.md, and list the following info:

+++
headless = true

[[menu_section]]
  heading = "Heading 1"
  text = "Text 1"
[[menu_section]]
  heading = "Heading 2"
  text = "Text 2"
[[menu_section]]
  heading = "Heading 3"
  text = "Text 3"
[[menu_section]]
  heading = "Heading 4"
  text = "Text 4"
+++

In Layout > Partials > menu.html, I’d like to get the information listed under each [[menu_section]].

So I’d like to do something like this (which I can’t get to work):

{{$headless := site.GetPage "menu"}}
{{range $headless.Resources.Params.menu_section}}
{{.heading}}
{{.text}}
{{end}}

I’ve tried various version of the above code using, Match, GetMatch, ByType, but I can’t get it to work. is this possible to do?

Any thoughts on this?

Wait more than 6 hours on a weekend to get free tech troubleshooting help.

I saw folks responding to questions on here in the past hour or so. As my question had fallen down I bumped it. Completely harmless, the direct opposite of what I assume you intended to convey with your comment.

Perhaps you should think twice before posting a comment like that does nothing except make someone feel bad?

You’re close. So you don’t need .Resources since the menu sections are not resources, they’re front matter params. I’d write it like so:

{{$headless := site.GetPage "menu"}}
{{$menu := $headless.Params.menu_section}}
{{range $menu}}
  {{.heading}}
  {{.text}}
{{end}}
1 Like

Thank you :facepunch:

I don’t want you auto-bumping posts. That sends out messages and notifies those of us trying to help people. I’m sorry if it made your feel awful, but thinking about it casually, if you feel bad about auto-bumping a thread, then do not; that was my intent.

I’m okay if you vocalize your assumption I meant harm by my comment, I can take it. But please refrain from talking to anyone else in the forums in this manner. I encourage you to be assertive and vulnerable (but definitely less auto-bumping!) :slight_smile: