Wednesday, August 8, 2012

The Site Is Not Valid The ‘Pages’ Document Library is Missing in SharePoint 2010

The site is not valid. The ‘Pages’ document library is missing.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.SharePoint.Publishing.InvalidPublishingWebException: The site is not valid. The ‘Pages’ document library is missing.

Based off this error I went to check to make sure the ‘Pages’ document library does indeed exists and is not missing.  To my surprise the ‘Pages’ document library was there.  So why am I getting this error?  I was a little confused.

This error is due to the Publishing feature storing a unique ID of the Pages library in the __PagesListId property which resides in the property bag of the publishing site.
The above listed error will occur if the value stored in the __PagesListId does not match the ID of the actual Pages library.

So somewhere between the Export/Import of the Site it lost its unique ID.
To fix this error you can run a PowerShell script to reassign/update the correct unique ID.
Below is the PowerShell script that will fix this problem.

$web = get-spweb http://portal/path-to-affected-site
$correctId = $web.Lists["Pages"].ID
$web.AllProperties["__PagesListId"] = $correctId.ToString()
$web.Update()

After running the script I attempted to create the Publishing Page again and it was created successfully with no error.

Note: I’ve only seen this error happen with an Export/Import of Sites to Site Collections in SharePoint 2010.

1 comment: