Post Migration – This page is not using a valid page layout


In case of publishing sites, when you export and import sites, the pages will throw “This page is not using a valid page layout” error.
This is due to the fact that PublishingPageLayout is hardcoded within the page itself and must be updated on the migrated site. If you want to investigate further, download the page and check for the value.

In my case, I was restoring a site collection (http://sharepoint/sites/ASITE/) as a subsite (http://sharepoint/ASITE/)using powershell (syntax below for example).

Export-SPWeb -Identity http://sharepoint/sites/ASITE/ -Path C:\Temp\ASITE.01.bak -IncludeUserSecurity -IncludeVersions All
Import-spweb -Identity http://sharepoint/ASITE/ -Path C:\Temp\ASITE.01.bak -IncludeUserSecurity -ActivateSolutions

The site http://sharepoint/sites/ASITE/ would work fine but this error would be at http://sharepoint/ASITE/

The PageLayout needs to be updated for all pages in the new site. There are many posts about doing this via powershell, and here is how mine looked like. Update the “WelcomeLinks” to suit your needs.

$spWeb = Get-SPWeb -Identity "http://sharepoint/ASITE/"
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
$pages = $spPubWeb.PagesList
foreach($item in $pages.Items)
{
$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
$url = new-object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString())
if($url -ne $null)
{
$itemPage =$url.Url
write-host $itemPage
if($itemPage -match'WelcomeLinks')
{
$newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://sharepoint/_catalogs/masterpage/WelcomeLinks.aspx, Welcome page with summary links")
$pubPage.Name
$pubPage.CheckOut()
$pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
$pubPage.ListItem.UpdateOverwriteVersion()
$pubPage.ListItem.File.CheckIn("Fixed PageLayout URL", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
}
}
}
Advertisements

6 thoughts on “Post Migration – This page is not using a valid page layout

  1. Pingback: Jean Paul's Blog | SharePoint 2010 – Moving Sites & Solutions

  2. Pingback: Jean Paul's Blog | Layout Problem after Export

  3. Michael Düpjohann

    Thanks for this Infos, it helps a lot!!
    I had one Error, but I could fix it:
    ERROR: Value cannot be null.
    At line:467 char:4
    + $pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $n …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], ArgumentNullException
    + FullyQualifiedErrorId : System.ArgumentNullException

    Solution:
    $newurl = new-object Microsoft.SharePoint.SPFieldUrlValue($web.Url + ‘/_catalogs/masterpage/YOURLAYOUT.aspx’);
    $newurl.Description = “Name of the Layout”;
    $newurl.Url = $web.Url + ‘/_catalogs/masterpage/YOURLAYOUT.aspx’;

    $pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl.ToString();

    Reply
  4. Xeeshan Tahir

    Thank you for the script. I got the below error while running this script. It took me more then an hour to troubleshoot and fix it.

    Error:
    Value cannot be null.
    At E:\temp\PageLayout.ps1:20 char:3
    + $pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $ne …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], ArgumentNullException
    + FullyQualifiedErrorId : System.ArgumentNullException

    Solution: Just add ” in below line to separate the parameters.

    Original > $newurl = new-object Microsoft.SharePoint.SPFieldUrlValue(“http://sharepoint/_catalogs/masterpage/WelcomeLinks.aspx, Welcome page with summary links”)

    Updated > $newurl = new-object Microsoft.SharePoint.SPFieldUrlValue(“http://sharepoint/_catalogs/masterpage/WelcomeLinks.aspx”, “Welcome page with summary links”)

    Hope it helps someone.

    Regards,
    Muhammad Zeeshan Tahir

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s