Fix publishing pages with custom page layouts created from template

This article is a continuation of my previous article that explains how to save publishing sites as templates.

Per the feedback received some people was not able to access the sites created with the template, this happens with sites that include pages with custom page layouts.

Before getting into details about how to fix this please notice that the previous article is a hack to save the site as a template, save site as a template is disabled in all Publishing sites and other type of sites with publishing features active, this means that the hack may not work in all SharePoint scenarios.

Page layout template error

The issue

After creating the site with the template the user is presented with the message above. It is displayed even if the page layout exists in the system.

All the pages with custom page layouts will became inaccessible and a reset to one of the default page layouts will be necessary.

Even though the message suggest that it can be fixed in the page settings, this page is also inaccessible and presents this message.

Page settings error

How to open the page settings?

You can open the page settings from the Content and Structure option in the site settings. To open the site settings from the site showing the error you can access directly to this link /_layouts/15/settings.aspx (e.g. https://dummy.sharepoint.com /_layouts/15/settings.aspx).

Once you are in the site settings click on Content and Structure located under site administration.

Select the Pages library, in the page with the custom page layout applied click in the name to the to open the context menu. From the menu select Edit Page Settings.

Page layout settings page

How to open the pages again?

This method requires you to run a custom PowerShell script to apply one of the default page layouts and it works for SharePoint Online and SharePoint OnPrem. The SharePoint online script can be executed in your personal computer, the SharePoint OnPrem script needs to be executed in your SharePoint server.

The PowerShell script is provided in the zip files bellow, download the zip file for your SharePoint version, extract the content and execute the ps1 file.

Download for SharePoint Online
Download for SharePoint on Premises

The script will request the following parameters:

  • Site URL: Provide the link to the site showing the error message and exclude the pages library and the page name (e.g. /pages/default.aspx)
  • Page Name: Provide the page name including the .aspx, you can copy it directly from the address bar
  • User Name: Provide your user name, this parameter will be requested only on SharePoint Online
  • Password: Provide your password, this parameter will be requested only on SharePoint Online
page layout fix powershell

After executing the script, refresh the page settings and you will find the warning message bellow.

You should select one of the available page layouts, even if the desired page layout is not displayed, after selecting the page layout save the page settings.

Note: After running the script only the page layouts of the original content type will be displayed in the page settings.

page layout error

Open the site created from the template, it will load with the page layout that you selected in the page settings.

Due to the different zones in the page layouts is possible that your page is not displaying any of the web parts included in the template.

To get the web parts back, edit the page and apply the original page layout.

apply page layout

Repeat this process to all the pages that are showing the error message.


One Response to “Fix publishing pages with custom page layouts created from template”

  1. Florian

    April 10, 2017

    Hi João,
    thanks for this post. This is awesome. I thought all the time that the content in article pages is not exported at all into my sitetemplate.wsp.

    Reply

Leave a Reply


Web developer focused on SharePoint branding, blogger, tech enthusiast. Traveling and sports are my addictions, knowledge and success are my daily motivations.