Page param with falling back to a site parameter not working

Hello! I would like to display content ID in the footer of the website with fall back to site content ID if content page does not have content ID.

From Param documentation I see it should do exactly what I intend to do but it does not seem to work and instead, for some reason displays the content ID from one page params on all pages.

In hugo.yaml I have:

params:
  contentId: 'abc'

In content page params I have:

params:
    contentId: 'xyz'

In the footer I have it as shown in the docs.

{{ .Param "contentId" }}

What happens is that xyz in displayed in the footer of all the pages when I build the site with hugo --cleanDestinationDir. Does anybody have any thoughts?

Your shown config and code is fine.

Without your layout sources here’s my educated guess.

The partial (or one above in the call chain) that contains your line of code is called using partialCached without a context.

This way it is only rendered once and reused.

Change it to just partial so that will we re-rendered for every page.

1 Like

Thank you so much, @irkode! I could not have figured it out on my own :slight_smile: Quickly tested and seems to be working as intended. Even found an example of this exact change (even though in this case they were adding this the cache not removing it).

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.