OrchardCMS/OrchardCore · error · InvalidOperationException

Zone not found while invoking 'render_section':

Error message

Zone not found while invoking 'render_section': 

What it means

`render_section` resolved the zone name on the layout, but the zone shape is null or empty. When the tag was invoked with `required:true`, the absence of the zone is treated as a template error and this InvalidOperationException is thrown; otherwise the tag silently renders nothing. It signals that the layout does not contain content for the named zone.

Solutions

  1. Check the zone name spelling against the layout definition (zones are typically lowercase in Liquid, e.g. 'footer').
  2. Set `required:false` (or omit it) if rendering the section is optional and an empty zone is acceptable.
  3. Ensure something actually populates the zone (theme layout, placement, or a module adding shapes to it).

Example fix

// before
{% render_section 'AsideSecond', required:true %}
// after
{% render_section 'AsideSecond', required:false %}
Defensive patterns

Strategy: fallback

Validate before calling

{% assign zone = layout.zones[section_name] %}{% if zone == blank %}{% // zone missing: skip or render default %}{% endif %}

Try / catch

try { await displayHelper.ShapeExecuteAsync(zone); } catch (InvalidOperationException ex) when (ex.Message.StartsWith("Zone not found")) { /* render nothing or fallback markup */ }

Prevention

When it happens

Trigger: `{% render_section name:'SomeZone', required:true %}` where `layout.Zones['SomeZone']` is null or empty — typically a zone no theme/layout ever populated.

Common situations: Copying a template between themes where the target theme never fills that zone; typos in the zone name ('Footter', 'Footer '); custom layouts that removed a zone still referenced by alternates; expecting a zone to exist only when a particular module/feature is enabled.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/59f900a4ecad76e5. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/RenderSectionTag.cs:33

        var layout = await services.GetRequiredService<ILayoutAccessor>().GetLayoutAsync();
        var displayHelper = services.GetRequiredService<IDisplayHelper>();

        var arguments = new NamedExpressionList(argumentsList);

        var nameExpression = arguments["name", 0] ?? throw new ArgumentException("render_section tag requires a name argument");
        var name = (await nameExpression.EvaluateAsync(context)).ToStringValue();

        var requiredExpression = arguments["required", 1];
        var required = requiredExpression != null && (await requiredExpression.EvaluateAsync(context)).ToBooleanValue();

        var zone = layout.Zones[name];

        if (zone.IsNullOrEmpty())
        {
            if (required)
            {
                throw new InvalidOperationException("Zone not found while invoking 'render_section': " + name);
            }

            return Completion.Normal;
        }

        var htmlContent = await displayHelper.ShapeExecuteAsync(zone);
        htmlContent.WriteTo(writer, (HtmlEncoder)encoder);

        return Completion.Normal;
    }
}

View on GitHub (pinned to 4306c0717f)