SharePoint 2010: Create a Custom Page Layout for a Publishing Site using SharePoint Designer

Creating a custom layout for a Publishing site in SharePoint 2010 is not very difficult to accomplish, but there are a few steps that that might cause you hang ups if you didn’t know where to look. I will show you how easy it is to quickly create your own custom page layout using a simple example.

Step 1

Open your Publishing site in a browser, and in the Site Actions menu, select Site Settings. On the Site Settings page, under Galleries, click on Master pages and page layouts.

Step 2

On the Master pages and page layouts page, in the Ribbon, under Library tools, select Documents. In the Documents menu, select New Document found on the left, and then in the New Document sub menu, select Page Layout.

Step 3

On the New Page Layout page, you will be asked to provide basic information regarding this page layout. By default you will want to leave the Content Type Group set to Page Layout Content Types and the Content Type Name set as an Article Page. You can set the URL name to a filename that describes this  layout although it is up to you. I suggest that you do not use spaces either. The Title is what will be displayed on the layout menu for a content page. The description can be left blank if you wish. Click OK at the bottom of the page once you are ready.

Step 4

Once the page layout has been created, you will be sent back to the Master Page Gallery. You will see that your new page layout has been added, although its Approval Status is marked as Draft. I am now going to skip a few steps as the next few steps depend on what you intend to do with this new page layout. By default, the new page layout will look similar to the image below in SharePoint Designer. To open the page layout in SPD, you can either click the page layout file name in the browser and select Edit in SharePoint Designer from the drop down menu, or you can simply open your site in SPD and navigate to the All Files->_catalogs->masterpage directory. The steps that I am skipping are updating the page layout. You can transfer over content areas from existing page layouts, make any updates as needed, etc. Don’t forget that you can grab content area id from your masterpage as well.

Step 5

Once you have made changes to the page layout as required, you will have to check in, publish and approve the layout before a content page can use it. Open the Master Page Gallery in a browser as before and click on your new page layout. On the dropdown menu, select Check In. On the Check In window, I suggest checking in a Major Version.

Your Approval Status should now be set to Pending. We now need to Approve this layout, so click on the on your new page layout again and on the dropdown menu, select Approve/Reject. On the Approve/Reject window, select Approved. This item will become visible to all users. and click OK.

Your new page layout should now be approved and ready to be used on a content page.

Step 6

You are now ready to add a new page (or open an existing page that you want set to use your new layout). If you would like to add a new page, click on the Site Actions button and in the Site Actions menu select New Page. You will only be asked for a page name. Go ahead and enter a new page name, in my example, it will be testpage1.

Step 7

You are seconds away. Once the new page has been added, you will be taken to the new page, already opened to be edited. Above the ribbon, select the Page option (between Browse and Publish). In the page menu, select Page Layout. In the Page Layout dropdown, you will see your new page layout. Select your layout, and you are done.

Summary

Once you click on the new page layout, it will automatically be applied to your page. If you followed these steps and did not make any changes to your new page layout then most likely once your new page layout has been applied, you will have a content page with not much to do. This is because the layout page we created doesn’t do much by itself. If will be up to you to modify the page layout content areas to add web part zones, controls, new layouts, etc.

Hopefully this has been helpful and once you have tried this a few times you will find endless opportunities to create custom page layouts as needed.

Do you have thoughts, insights or suggestions regarding this post? Please tell me.

Comments

  1. Hi Eric, It’s really informative article. I have question though. How can i create a page template so that author can create a blocks of content? This block is itself a template.
    I mean I have a Page Layout like

    [ //This block is like a table of content
    //These Bulleted blocks are hyperlink which are deep link to their contents.
    Block1 heading Block2 heading
    Block3 heading Block4 heading
    Block5 heading Block6 heading
    ]
    //Various Sections
    {
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
    }

    Should I create any control so that author can add these details and the content is added to the page whenever author need to add new block?

    Please Suggest.
    Thanks
    Khushi

    • Hi Khushi,

      Could you use custom Markup Styles to accomplish what you are looking to add? I have been looking to write a more detailed blog post on custom Markup Styles, but basically when editing a page, go to the Format Text tab under Editing Tools and look for Markup Styles.

      To add a custom Markup Style, add custom css to your custom stylesheet similar to:
      DIV.ms-rteElement-PMCustom2
      {
      -ms-name:”PM Custom 2″;
      }
      .ms-rteElement-PMCustom2
      {
      font-size:2em;
      font-weight:normal;
      color: #f00;
      text-align: right;
      border: 1px #000 solid;
      }

      What this allows you to do is create a custom div tag, header tag, span tag, etc that can be automatically placed around a content block with custom styling. This is a very powerful tool for basic content markup.

      These markup Style blocks can be added into general content editors as well as Content editor web parts.

      I hope this helps.

      Eric

  2. Hi Eric,

    Will i be able to add another Page content field into the page, to inserts only image with fixed size and location(right/left).

    Thanks,
    Anu

  3. Disgruntled says:

    You give a guide for creating a Page Layout in SharePoint 2010. Unfortunately the only steps you give are the ones that people would be able to figure out how to do on their own. The hard part (without adequate documentation) is precisely the part you say you are leaving out (see step 4). I guess I’ll have to keep looking.

  4. Isabel says:

    Hi Eric!

    I have a quick question regarding what a person would expect to see as a site owner. Your pictures above seem to show that if you add a page to your site, that page would show the Publish tab in the Ribbon. I am using a CloudShare site to train some people at a company and want to give them the a realistic view of what they will actually see, but I think my rights aren’t quite set up correctly. I am on a publisher site and have the Publisher tab in the Ribbon on my Home page, however, when I create a new page I only get a Page tab on the Ribbon. I can add the Publisher tab by going into the Pages Library, clicking on Advanced, then choosing to Require Approval. However even then the Publish button is greyed out.

    Can you confirm that I should see the Publish tab in the Ribbon in a Publishing Site with proper permissions?

    Thanks so much for your help, Eric!

    Isabel

    • Hi Isabel,

      Based on what you are describing it sounds as though SharePoint 2010 is behaving correctly.

      The publishing tab will only appear on sites and pages that require approval, which you were able to see because you only had a publishing tab once you turned this on.

      Now once this has been turned on for a given page, the publishing tab appears, but the Publish button in the Publishing ribbon is greyed out. This is most likely because you have either not now checked in the file, or you have not yet Submitted the page for approval. There should be a Submit button next to the Publish button. Side note, you should be able to enable the Pages list so that all list items (pages) require content approval.

      A few more notes. I have found that if I am logged into a site as a site collection admin and submit a page for approval, once I then click on the Publish button I am eventually told my SharePoint that I do not have any pending publishing tasks. Really frustrating. I have found that even though I am a site collection admin I have to add my account to the Approvers list as well. Someone may be able to tell us why this is required, but I do not have a good answer myself.

      I hope this helps.

  5. Thnk u.. awesome explanation

  6. Hi, I created the layout as you instructed, but noticed in SPD 2010 that the layout is broken from the site definition. I don’t think that is a good practice since the layout will pretty much be a rogue file and not associated with the site def. In MOSS, I was able to create custom layouts that did not break from the site definintion. In SP 2010, any customization results in breaking from the site def. Any input on this? Thanks!

    • Hi Frank,

      You have brought up a good point that I didn’t think to cover.

      Using the steps that I specified in this blog post, Sharepoint is creating a new page layout that is ghosted. Learn more about ghosted and unghosted here. This means that once you then try to make an edit to the file, you end up unghosting it, thus it is no longer linked directly to the site definition, i.e. single, cached version. This is not a deal killer although there is a performance hit because your page layout is now stored in an unghosted form as well.

      You can kind of get around this by adding your page layout directly in SPD by copying and pasting a Page Layout into your _catalogs/masterpage folder, but I believe that adds a new page layout that is not ghostable in the first place. This would mean a similar performance hit.

      Second technique? Well you could add the Page Layout via a feature that you built in Visual Studio 2010. This way you can modify the elements.xml file defines where your page layout goes in the Master Page Gallery so that it is ghostable as well as pre-defined with the layout you desire. If you go this route I suggest that you create and debug your page layout first using the technique in the above post or my other suggestion, adding the page layout in SPD. Then once you are happy with new page layout, go ahead and add your page layout to a feature and install/activate the feature. Your correct page layout is now ghosted.

      This isn’t as easy as in MOSS, but should work.

  7. Thanks

    • Thanks..!! Could you please post or send some link to Create a Master Page or How to edit the master page (Adventure Works) for a Publishing Site using SharePoint Designer.

  8. Hi Eric,

    Thanks for the article, am new to SharePoint, I want to ask how can I create page layout that has image and some fields displayed on the page, my problem is that I created “Single line of text field” and other URL fields, and I can’t show them on my page.

    I have to show users title of news and image for news. I have the title as single line of text field and the image as hyperlink field to the image. is there any way to do this? or anything I don’t know about? Thanks

    • You will want to look into the TextField Control or the FieldValue Control to access the metadata of a particular page.

      Both Controls are found in the Microsoft.SharePoint.WebControls namespace so a common Register tag found in most Page Layouts may be:

      <%@ Register Tagprefix=”SharePointWebControls” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

      Assuming this, you could then display your Title field while in Display mode or a editable text box while in edit mode with the following in your page layout.

      <SharePointWebControls:TextField runat=”server” FieldName=”Title” />

      Say you only wanted to display the Title field, then you could use:

      <SharePointWebControls:FieldValue FieldName=”Title” runat=”server”/>

      A Rich Image (Really a publishing Image) may use:

      <PublishingWebControls:RichImageField FieldName=”efs_Image” runat=”server”/>

      I hope this quick overview helps you get started.

  9. Hi Eric,

    After clicking on the link “Master Page and Page layout” under “Galleries” in “Site Setting” I am getting the error “File Not Found”. Did I forgot to activate any setting? I had activated “SharePoint Server Publishing” in “Manage Site feature” and “SharePoint Server Publishing Infrastructure” in “Site collection feature”

    Thanks,
    Namrata

    • Hi Namrata,

      If you activated both the site collection and site level publishing features, yet you get a File Not Found error when you navigation to the Master Page Gallery, i.e. ~sitecollection/_catalogs/masterpage/Forms/AllItems.aspx, that does not bode well. If you are receiving a 404 error then it sounds as though the Master Page Gallery library has become corrupt. I do not know of an easy way to fix this besides rebuilding the site collection.

      Eric

Speak Your Mind

*


three − 1 =