/content/posts/bla2/index.md <-- this file has the frontmatter variable?
And then in the footer of the page something with that one (or more) page(s) where the variable is set?
Research and learn about scratch. It’s a bit more advanced. You collect stuff and reuse later.
A specific use-case would be interesting so we can wrap our heads around it. You could also just get the page object of the current page and then iterate through it and see if there is anything in the frontmatter in each one in your footer template. But then you might have lots of unused loops depending on the page size.
The other way around. I have this page C:\hugo_blog\themes\kiss\layouts\index.html <-- I want to set variable here
and I have C:\hugo_blog\themes\kiss\layouts\partials\footer.html <-- where the script is added on condition
PS: It works already like this:
C:\hugo_blog\content\posts\blogPost1.md <-- I set the variable here
C:\hugo_blog\content\posts\blogPost2.md <-- I dont set it here
C:\hugo_blog\content\posts\blogPost3.md <-- I set the variable here
UPDATE: The .Scratch solution worked! Very handy feature, thanks man!