To set the stage:
I have a collection document called l01.md that uses the 'narrative' layout. The narrative layout uses the 'default' layout.
The narrative layout includes a file that assigns a variable 'page-contains-audio' that is used later in the layout to add the audio player html. This all works as expected.
But when the default layout is processed it includes head.html which includes a js lib and some css when the page-contains-audio variable is true.
But the variable page-contains-audio is not set at this point.
I realize I may not understand how layouts are rendered - I've got an inside out notion of how it is done. Starting with the collection file: l01.md then to the narrative layout and then to the default layout. If this is how it works I was assuming that a variable assigned at a lower stage in the process (the narrative layout) would be available at higher stages (the default layout and what it includes).
What am I missing? What is the correct way to do this?
Thanks in advance.