--- layout: default permalink: templates/layouts/ title: Layouts --- Layouts ======= The `layout()` function allows you to define a layout template that a template will implement. It's like having separate header and footer templates in one file. ## Define a layout The `layout()` function can be called anywhere in a template, since the layout template is actually rendered second. Typically it's placed at the top of the file. ~~~ php layout('template') ?>
Hello, =$this->e($name)?>
~~~ This function also works with [folders](/engine/folders/): ~~~ php layout('shared::template') ?> ~~~ ## Assign data To assign data (variables) to a layout template, pass them as an array to the `layout()` function. This data will then be available as locally scoped variables within the layout template. ~~~ php layout('template', ['title' => 'User Profile']) ?> ~~~ ## Accessing the content To access the rendered template content within the layout, use the `section()` function, passing `'content'` as the section name. This will return all outputted content from the template that hasn't been defined in a [section](/templates/sections/). ~~~ php