Home > Publishing, SharePoint > This page is not using a valid page layout in SharePoint 2010

This page is not using a valid page layout in SharePoint 2010

In this post, I’ll show you how to overcome the error ‘This page is not using a valid page layout’ when moving around content from one publishing site collection to another in SharePoint 2010.

It’s a problem I’ve come across a few times as it’s been around since MOSS.  It occurs if the relative path between site collections or web application is different and therefore breaks the link to PageLayout.  For example moving these pages:


to a subsite


will result in an invalid relative link to the pagelayout, in this case it will be http://intranet/sites/wiki/_catalogs/…. so as you can see there is an erroneous sites reference within the link.

Initially it’s best to view the current Pagelayout assigned to each page, to do so you can use this script, replace [Site URL] with the url of the site containing your publishing pages.

$Site = "http://[Site URL]"

$web = Get-SPWeb -Identity $Site
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$publishingPages = $publishingWeb.GetPublishingPages()
foreach ($publishingPage in $publishingPages)
  write-host $publishingPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout]

To resolve the issue, I wanted a flexible solution which could work with any pagelayout or even replace them if needed and therefore opted for a script which used a simple search and replace.   In the following script, update the [Site URL], the [Search for] for the string to search for, for example the old link and [Replace with] for the new value, such as the new site.

$Site = "http://[Site URL]"
$SearchFor = "[Search For]"
$ReplaceWith = "[Replace With]"

$web = Get-SPWeb -Identity $Site
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$publishingPages = $publishingWeb.GetPublishingPages()
foreach ($publishingPage in $publishingPages)
  $url = $publishingPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout]
  if ($url -match $SearchFor)
    write-host Updating Page Layout for $publishingPage.Name
    $newurl = $url -replace $SearchFor, $ReplaceWith
    $publishingPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
    $publishingPage.ListItem.File.CheckIn("Corrected page layout URL", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
Categories: Publishing, SharePoint
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: