Can I set a $.Param from within a partial?

Is there a way to set a $.Param from within a partial? I know it can be set from the front-matter, but I’m trying to tidy up my current workflow.

No, that is not possible. Not sure if that would even make sense. If you describe your problem better, maybe we can suggest something different.

Hi bep, thanks for coming back to me.

Awesome job on Hugo, btw. Thanks for Hugo again!

I’m simply trying to deal with jQuery on my template. In some pages, I use the slim version, in others, I use the full version, in others, I don’t use it at all.

As of now, I am doing it by defining which version I want on my front matter

Title = "Page"
Top_jQuery = "true"
Full_jQuery = "true"

What I wanted to do was to be able to set those variables from within a partial, since they are not site wide variables, but page specific variables for each page (say, About has a Slim version of jQuery running while the Contact page has the full version, on the header instead than on the footer)

Any help is appreciated.


Not sure what you’re need is.

If you want to access a Page variable from within a partial, you need to pass its context as parameter:

{{ partial "footer_scripts" . }}

The dot above … . . . . . … … … … … :point_up_2: is your context passed as parameter.
Now from within your partial, the dot is that page context.

Now considering you have passed this page context to your partial, you can use its .Scratch to attach any custom variable to this page.

So you could have a partial on top of your baseof.html which set some .Scratch variables to the page, and then, alll those .Scratch value will be available for later use.

But, I’m not sure it applies to your need, because your .Params will always be available to you from a partial, as long as you pass the page context as parameter :smiley:

1 Like

Thanks! Didn’t knew about Scratch!

Is there a way to read a /shortcodes/file.html from /partials/ ?? I can’t seem to be able to read them.