In this tutorial, you will learn how to create a master layout and apply it to a page within a Umbraco CMS-powered website. MVC layout within Umbraco. Let us get to business 🔥🔥🔥 First, log into the Umbraco backend. Within the Settings section in the left-hand main menu, right-click on the Document Types folder and select Create. To keep Umbraco well organized we will create a new folder:

umbraco_create_first_page_2

This folder is where you will add all your base document types. In this example, I name the folder master as I'm only planning on creating one master document type. Other good names for the folder would be, global, or shared. Use whatever makes you happy 🙂.

umbraco_create_first_page_3

After creating the folder, it is time to create the master document type. This document type is going to be the base template that all other document types inherit from:

umbraco_create_first_page_4

I want to have a page title property that can be used in the head section on all pages. I want this property to be common on all of my document types. This is why I am adding it to the master document type. Make sense? After creating the title property, click save:

umbraco_create_first_page_5

Clicking save in the editor will not only create the new document type within the Umbracos database, but it will also create a corresponding view file in the view folder in the webroot and for a Umbraco template. In case you are still unsure about what a template is, it's the thing that defines the HTML. Templates relate to MVC views. Instead of writing some custom HTML, for this guide, for laziness and speed, I'm going to copy the basic template HTML from the bootstrap site, which is available from this page, within the basic template section, here and the CDN links here.

umbraco_create_first_page_6

For your reference, I'll include some example HTML that you can copy and paste to help you get going. Notice the important past here is a call to RenderBody(). This code snippet will get the associated page HTML and injected it into the layout when the page is being rendered (we will create a page shortly 😉).

We now have a master document type, next, we need to create a page document type with a corresponding template. For this example, I will create a document type called homepage

umbraco_create_first_page_7

Still keeping within the Umbraco Document Typesfolder, right-click on the master document-type and from the context menu select Create. Create a new document type and call it Homepage. You can leave most of the settings empty for now:

umbraco_create_first_page_8

Make sure that the option 'Allow As Root' is enabled. This option will allow you to create a page using the homepage document type underneath the root node in the content tree. This is important, otherwise, you will not be able to create a page later on 😣.

umbraco_create_first_page_9

With the homepage document type created, if you look in the Templates area in the CMS again, you will see a corresponding 'Homepage' template has also been created. If you open the template, an HTML editor will load that will allow you to add HTML to the template. Notice that the layout property is set to null. We will now change this to use the master layout we created above.

umbraco_create_first_page_10

In the Properties tab, see the Master template selector is set to the master document-type you created. Do not forget to click the 'Save' button after adding any HTML:

umbraco_create_first_page_11

When the page refreshes, you should now be able to see that the layout property has been set to the master template!

umbraco_create_first_page_12

Next, we will create the home page in the content tree. Within the Umbraco backend, go to the Content section on the left-hand side menu. Right-click on the Content menu item and you should now be able to select the homepage document type you just created. Create a new page using this document-types and set it as the home (see, How To Set The Start Page In Umbraco 7. Publish the page so it goes live!

umbraco_create_first_page_13

When you view your website on the root domain e.g. www.websiute.com a page should now render. That is everything you need to create a master document type and an associated child document type 😀. You are now one step closer to becoming a Umbraco ninja 🌪🌪🌪. Happy Coding 🤘