After trying to deactivate and activate the publishing feature in a site, users started receiving this error: “The site is not valid. The ‘Pages’ document library is missing”. It also happened after importing a subsite backup! Additionally, when tried creating a Publishing Pages, they got this error:
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.
SharePoint Publishing feature stores the ID of the “Pages” library in the “__PagesListId” property of the SPWeb property bag. If this property doesn’t match with the current “Pages” library, then we get this error! I made sure the publishing feature was active and tried to deactivate and activate it again, but it didn’t help!
To fix this error, We’ll have to set the “__PagesListId” property on the affected web’s property bag!
PowerShell Script to Update the Pages List ID:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebURL="https://SharePoint-Site-URL" $Web = Get-SPWeb $WebURL $PagesListID = $web.Lists["Pages"].ID $Web.AllProperties["__PagesListId"] = $PagesListID.ToString() $Web.Update()
This PowerShell script updates the property and corrects the problem.
Update Property Bag Settings using SharePoint designer:
You can also use SharePoint Designer to fix this problem. Here is how:
- Get your “Pages” library’s ID first! Here is How to get SharePoint list GUID
- Open the SharePoint site which has this issue in SharePoint Designer
- Select the site object in the tree view and Click on “Site Options” button from the ribbon
- Check if the property “__PagesListId” exists, If so, update its value to current Pages library ID.
- If the Property doesn’t exists, Click on Add button to add the property. Enter “__PagesListId” as property name and value as the “Pages” Library GUID
- Save your changes.