Frontmatter parameters do not update when clicking contextual links (Netlify)

Hey, I’m pretty new to Hugo so I’m not sure whether I’m missing something obvious.

For my Netlify site, I use the “css” parameter to change the css. The index page has the css parameter “index”, and another page has the css parameter “official”. Clicking a link from the index page to this other page does not change the css parameter to “index” as expected, so the “index” theme is shown instead of the “official” theme.

Reloading the page does update the frontmatter, however this is not a viable solution for me.

Thanks in advance for any help!

Could you share what the frontmatter looks like and where you’re using the CSS variable in the template? It might help to debug your issue.

Not very clear. A hugo parameter can not change once set because it’s a static site generator. Did you mean to set up the initial value of a css custom property ?

Here’s what the front matter for the index page looks like:

title: "Index"
css: "index"

This is what the frontmatter for the “official” page looks like:

title: "Notice Board"
css: "official"

I used a partial in my head.html file to link to css using syntax like:
{{ if eq .Params.css “official”}}

{{ end }}

When I was debugging I noticed that when I clicked a link to another page, the “css” parameter from that frontmatter did not update.

Sorry if my terminology is wrong, as I’ve said I’m new to Hugo. Hopefully the images clear things up.

This is a feature of the theme you are using. We need to see your code to be able to help you. Best to post a link to your repo.

Again, that doesn’t make any sense. Parameters are neither dynamic nor mutable. To know if {{ if eq .Params.css “official”}} works as a precondition to add code, put something very visible or just easy to check in the html source. Write aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa and if it’s not there, it’s a bug. If it’s not, then you don’t understand what your theme and code actually does.

Sorry, I meant the variables in the frontmatter for each of the pages.

Here is the github repo for reference:

Sorry folks, I found a solution. I used Jacky Zhao’s Quartz to run the Netlify app, and didn’t realise that it was using Million’s routing to make the website a SPA. Turning this off fixes all the issue.

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