Saturday , 23 August 2014
You are here: Home | Hot Topics | Best Practices | Creating a Custom Page Layout in SharePoint 2013

Creating a Custom Page Layout in SharePoint 2013

In my last article, I documented how to create a Master Page in SharePoint 2013.  Master Pages define the global chrome elements of your web site.  This article explains how to create custom page layouts in SharePoint 2013.  For more information on the SharePoint 2013 page model, see this Microsoft article.

Planning Out Your Page Layout

For this example, we’re going to recreate a chunk of a page on our web site (www.navantis.com):

 

In our previous article, we created Master Page that defined the header, footer and global style sheets for this page.  Now we’re going to create a page layout that follows this basic format.  The content will be dynamic so that you could create as many pages as you like based on this layout.

In our page layout, we’re going to define the following areas as “field controls”.  We’re going to create them all in a single content container and lay them out explicitly in order to reflect our design:

 

The breadcrumb on the top left we can use SharePoint’s breadcrumb trail and we will embed the newsletter subscription into the page layout because we don’t want this to be explicitly defined into the layout.

Defining Your Content Type

So before we do the HTML work, let’s create a content type (a definition for content fields) that defines each of these fields for our page.  Based on the above plan, we need the following fields:

  • LargeHeadline
  • RightHandBlurb
  • LeftLinkList
  • LeftColumnTitle
  • LeftColumnText
  • RightColumnText

In each case, these will be HTML controls.  SharePoint 2013 allows you to define other types of content for these fields such as images.  Images in SharePoint 2013 can be rendered in specific dimensions and SharePoint 2013 will dynamic render any image to that specified to ensure they fit nicely into your defined layout.

To create a content type, go to Site Settings –> Site Content Types (under Web Designer Galleries).  If you look at Page Layout Content Types you will see existing ones for Article, Catalog, Welcome Page, etc.  We’re going to create a content type for our layout.  Click on Create and type in a name for your new content type:

Under Parent Content Type, you can select the parent your content type will inherit from.  If you look at the existing page layout content types, they inherit from the content type Page.  Page is in the group Publishing Content Types.  You can also specify the group you want to place your new content type – you could add it to the existing Page Layout Content Types group or create your own custom group.

 

When you have created your new content type, SharePoint 2013 will display the columns that were inherited automatically from the Page content type.  Lets add some new ones to represent our custom fields.  Click on the Add from new site column and let’s add each field:

 

For each column, we can specify the type.  For those fields we want to explicitly style, we can use the Single Line of Text option to have the content author put in plain text that will be formatted by the template.  For those fields that we want to provide more control to the content author, we can specify the field as Full HTML content and then content author will be able to put in any HTML using the rich text editor.    For our fields, let’s use this approach:

    • LargeHeadline – Single line of text
    • RightHandBlurb – Multiple lines of text
    • LeftLinkList – Full HTML
    • LeftColumnTitle – Single line of text
    • LeftColumnText – Full HTML
    • RightColumnText – Full HTML
 

For each field, create a site column.

Now we have fields to store the content, let’s now create a Page Layout.

Creating a Page Layout

To create a page layout, go to the Design Manager and Click on 6. Edit Page Layouts.  Click on Create a Page Layout.  Give your page layout a name, pick your master page and your content type you just created.

 

If you preview your page layout, you will see it doesn’t look like much – we need to update the HTML around the field controls to properly format the layout.

Publishing Your Page Layout

Before you can use your page layout, it has to be published.  To publish your page layout, go to Site Settings –> Master pages and page layouts.  You will see two files – one is HTML and one is ASPX.  in SharePoint 2013, the HTML is now the master and you can edit it using an HTML editor.  SharePoint 2013 then generates the ASPX file automatically.  To publish your layout, click on the HTML file and then Publish:

 

This will publish both the HTML and ASPX files, now making them available to create a page based on your layout.

Creating a Page

To create a page based on our new layout, go to New Page.

 

If you then go to Page –> Page Layouts you will find our new Page Layout in the list of available Page Layouts.  When you switch the page layout, you should now see all the fields that we created earlier in our content type.

You can fill in your content either by typing it in or copying and pasting it from either your existing web site or from office documents such as Word.  The copy and paste has improved dramatically over previous versions!

Here is my content now filled out:

 

 

Now we can publish our page…

 

Our content is there, but the layout doesn’t reflect what we want…so now edit the HTML to update our layout.

Customizing Page Layouts

Page layouts in SharePoint 2013 are just HTML files with a lot of additional markup to specify where the controls are going to be injected.  We can now customize the HTML file through the design manager.  You can simply grab a copy of the HTML file, make your changes and re-upload your file and SharePoint 2013 will do the rest.  There are two ways to grab the file:

  • Go to Design Manager –> 3. Upload Design Files and map a network drive to your master page directory.
  • Go to Site Settings –> Master pages and page layouts and you can download your file.

After iterating a few times with the page layout and moving the snippets provided by SharePoint 2013 into the appropriate spots, we now have a nicely formatted page:

 

All the content within the main page area is fully managed by SharePoint can be easily changed by a content author.

 

 

13 comments

  1. Thanks for the article! Do you have any tips for HTML editing now that we cannot use all the nice visual SP Designer features?

  2. There is a SharePoint Designer for 2013 – you can download it here…
    http://www.microsoft.com/en-ca/download/details.aspx?id=30346

    It has a reasonably good HTML editor built it and you can use it to go in and directly edit Master Pages and Page Layouts. You can also use any other HTML editor that you like, e.g. Dream Weaver. Visual Studio still works in a pinch as well.

  3. Great Article. When I am almost done. I could not find our custom pagelayout under pagelayout option. (Page-Pagelayout). Do you what exactly I missed?

    Thanks

    • Hi Tony:

      One thing to look for – you have to publish the page layout or it won’t show up…see my blog post for more details but this will definitely impact the page layout not showing up.

  4. Great Article. When I am almost done. I could not find our custom pagelayout under pagelayout option. (Page-Pagelayout). Do you what exactly I missed?

    Thanks

    • Hi Tony:

      One thing to look for – you have to publish the page layout or it won’t show up…see my blog post for more details but this will definitely impact the page layout not showing up.

      • Hi Woodill

        Is is necessary to create the masterpage (the one you created) before creating the pagelayout? Or I can simply use the default like OSLO. Becasue even after publishing the pagelayout I can not see it under pagelout category. Please help. Thanks

  5. Thanks for your reply. I did publish i.e. the htm only and asp is automatically published. Even though it doesn’t show up. Spending alomost two days but did not find the solution. Could you please add the image or state in more details.

    Thanks

  6. Thanks for your reply. I did publish i.e. the htm only and asp is automatically published. Even though it doesn’t show up. Spending alomost two days but did not find the solution. Could you please add the image or state in more details.

    Thanks

  7. Hey Tony

    I think you are using Beta Version of SP 2013. I got the same issue with the Beta version. It works good with the rtm. Good Luck!!!

  8. Hey Tony

    I think you are using Beta Version of SP 2013. I got the same issue with the Beta version. It works good with the rtm. Good Luck!!!

  9. Hello,
    first of all i wanna start thanking you for this great tutorial, it has been really helpfull to me and it was really nice from you to share your knowledge about the new version of this product.

    So le’ts get to the point.. I was wondering, during the process of design of website there is the need to upload the masterpage or the page layouts several times to make all the different changes and test them to reach the desired result.. what I find weird is the fact that even though i am uploading the same html file with changes since it has the same name of the one already on the server this forces me everytime to delete the old one and then uploaded the new one.. is there a way to avoid this? is there away to subscribe it directly? or how do you think i can avoid this waste of time?
    Looking forward for a feedback
    Thank you

    Best regards

    Davide Facente

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>