How to access another page's params

I have a bunch of pages I’m linking in a partial. These pages have their own content defined in their <page_name>.md’s frontmatter. I need to access the params in those pages like how I would in their their layouts or single.html, but in a partial.

Example:

//content/page1.md
title: Page1 Title
//content/page2.md
title: Page2 Title
//layouts/partials/featured.hml
{{ Page1.Param "title" }}
{{ Page2.Param "title" }}
//layouts/page3/single.html
{{ partial "featured.html" . }}

Is there a way to do this?

2 Likes

Thanks a lot!

I’ve found that if you need to access a Draft Page’s params (which will not be accessible via .GetPage that transform.Unmarshal works if you are able to navigate to the file and read it (.readFile https://gohugo.io/functions/readfile/)

1 Like

Great to know! Bookmarked.

Would you mind looking at Using .GetPage in a menu loop. I’m trying to use .GetPage in a menu loop.