Scenario:
Trying to create a new page fails with this error:
Microsoft.SharePoint.Publishing.InvalidPublishingWebException: The site is not valid. The 'Pages' document library is missing.
at Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingListWithCleanup(PublishingListType list, Boolean throwExceptionOnInvalidWeb)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.get_PageListRoot()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.SetParentUrlLabel()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.LoadValues()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.CreatePagePage.LoadValues()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.OnLoad(EventArgs e)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.CreatePagePage.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Fix: runt this PowerShell script:
$web = get-spweb http://site:port/web
$newId = $web.Lists["Pages"].ID
$web.AllProperties["__PagesListId"] = $newId.ToString()
$web.Update()