Here's how it breaks down:

✅ What’s working:

You set the variable in the Layout:

twig
{% set layout_name = "layout_default" %}

And then access it in the Layout itself:

twig
<p>Layout in use: <code>{{ layout_name }}</code></p>

That’s why it renders correctly there.


🧩 What’s going wrong in the Partial:

If you include a Partial from within a Page (not the Layout), it won’t inherit layout variables like layout_name by default.

Why?
Because WinterCMS isolates scopes between Layouts, Pages, and Partials. Layout-scoped variables like layout_name are not automatically passed to Partials included from Pages.


🛠 How to fix it (3 Options):

Option 1: Pass the variable explicitly to the Partial

This is the cleanest and most maintainable way.

In your Layout or Page where you include the Partial:

twig
{% partial "your-partial-name" layout_name=layout_name %}

Then inside your Partial:

twig
<p class="card is-full-width">Layout in use: <code class="card">{{ layout_name }}</code></p>

Option 2: Set the variable globally using this

If you're using a controller (like in a plugin or component), you can do:

php
$this['layout_name'] = 'layout_default';

This makes layout_name available to everything—Layout, Page, Partial.


Option 3: Setting in the Layout and expecting it to be visible everywhere

This won’t work in WinterCMS unless you pass the variable explicitly. Layout variables are not global across all templates.


✅ Summary / TL;DR

You’re almost there! Just pass layout_name to the Partial manually when calling it:

twig
{% partial "your-partial" layout_name=layout_name %}

Let me know if you'd like me to review your theme.yaml or directory structure just to ensure Partials/Layouts are in the correct places too. Want a diagram of the rendering hierarchy?