Creating a Layout Template
The previous articles covered how to create a Document Type and its corresponding Template. To build a site with Home, News, and Contact Us pages, create a Document Type with a corresponding Template for each.
You may end up copying the same HTML code into each of these templates, which can be time-consuming and repetitive. In such scenario, you might want to consider creating a new layout template.
To create a new layout template:
Go to Settings.
Select the ... next to the Templates folder. Alternatively, click + to open a blank template.
Click Create. A template opens up in the content editor.
Enter a Name for the layout template. Let's call it Layout.

Layout Template Click Save.
Using the Layout Template
To use the layout template:
Go to Settings.
Expand the Templates folder from the Templating section.
Open the Homepage template.
Select
Layout template: No layout. The Layout template dialog opens on the right-side of the browser.Select the template called Layout.
Click Choose. The Razor code section is updated from
Layout = null;toLayout = "Layout.cshtml";
Adding Layout Template to HomePage Click Save.
Updating Templates With the New Layout Template
Let's move the parts of the HTML template that are common across all templates into the Layout. It might be slightly different for different websites. You'll need to consider if all pages contain a <div id="main"> section so that you can update it in the layout.
To update templates with the new layout template, follow these steps:
Go to Settings.
Expand the Templates folder from the Templating section.
Navigate to the Homepage template.
Cut everything from the
<!DOCTYPE HTML>(around line 8) to the end of the</div>tag (around line 44). It is theheaderandnavigationof the site to the layout template.
Header and navigation tags selected in the HomePage template Click Save.
Go to the Layout template and paste this HTML markup after the closing curly brace (around line 7).
Add
@RenderBody()at the end of the markup. This will tell Umbraco to insert the child template's content.
Adding renderbody in the Layout template Click Save.
Repeat the same process for the footer content:
Go to the Homepage template.
Cut everything from the
<!-- Footer -->tag (around line 109) to the end of the</html>tag (around line 123).Click Save.
Go to the Layout template.
Paste this HTML markup after the
@RenderBody()field.
End of the Layout template
Click Save.
Now, a lot of work is done. Refresh the localhost page, nothing should change. If you have a compilation error you have perhaps mistyped @RenderBody().
If you are missing any content such as header or footer, ensure that the templates matches the following:
Last updated
Was this helpful?