Section Tag

The section tag is a useful way to abstract and reuse your views by extracting a section of markup that can then be rendered elsewhere with a yield tag.


Most commonly this section/yield approach is used to create a global area in your layout that can be changed by your templates. This eliminates the need for any brittle and messy logic.


  • No thank you: {{ if template == "news" }} hardcode something {{ /if }}
  • Yes please: {{ section:something }} + {{ yield:something }}


In the example below, everything within the section:sidebar tag will not be rendered in the template, but rather in the layout.

// The Template

<h1>{{ title }}</h1>
{{ content }}

{{ section:sidebar }}
  <h2>About the Author</h2>
    {{ author:name }}
  {{ author:bio }}
{{ /section:sidebar }}
// The Layout
    <title>{{ title }} | {{ site_name }}</title>
      {{ template_content }}
      {{ yield:sidebar }}

If you haven’t read up on templates and layouts, you should. It’s relevant.

Betterify this page on Github!