Using named sections in Umbraco
Template sections support the ability to add additional Named Sections to layout templates. These sections can be defined anywhere in the layout file (including within the section of the HTML) and allow you to output dynamic content in your template.
You can define a part of your template as a named section by wrapping it in @section
. This can be rendered in a specific area of the parent of this template, by using @RenderSection
.
For example, you can define the following section within a child template like a Content page:
To define a Named Section, follow these steps:
Go to Settings.
Navigate to a template and click Sections.
Select Define a named section and enter the Section Name.
Click Submit.
Renders a named area of a child template, by inserting a @RenderSection(name)
placeholder. This renders an area of a child template that is wrapped in a corresponding @section [name]
definition.
For example, you can define the following section within a Master template:
To render a Named Section, follow these steps:
Go to Settings.
Navigate to a template and click Sections.
Select Render a named section and enter the Section Name.
[Optional] Select Section is mandatory. This means that the child templates need to have the named section defined for them to work.
Click Submit.