Tuesday 6 January 2015

The site is not valid. The 'Pages' document library is missing.

I have faced this issue couple of times on my SharePoint site and thought to post this issue on my blog, so as to help others who might be facing the same issue

Error Information

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.

Note: After I received this issue, I tried with different options like deactivating and activating publishing feature at site level, directly tried to access the pages library but I could not found it etc.

 What can cause this issue

        Let me give some background information about the publishing feature . Publishing feature stores the 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.

        When user try to deactivate and activate the publishing infrastructure feature at site collection level, there are times where it asssigns a new _pagesListId value, by which it looses its connection with the id of the pages library.

Issue Fix

      I was able to resolve this issue by executing the below powershell script to update the _pagesListId value to match with the current pages library.


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