Common Error: The site is not valid. The 'Pages' document library is missing.

In the past I had a couple of cases where users received the following error message:

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.

The interesting piece here is that the Pages library indeed existed but could not be found.

Background Information

To understand this we need to look into how the Publishing feature find the Pages library in a Publishing site. As the Pages library does not need to have the name “Pages” – e.g. in German version it has the name “Seiten” SharePoint does not search for the Pages library by name.

Instead the 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.

What can cause this problem?

Honestly: I don’t know. I have not managed to forcefully cause such an inconsistency – if one of you has repro steps, please post a comment here!

How to fix the problem?

To fix the issue it is required to update the value of the __PagesListId property value to match the ID of the Pages library.

This can be done (e.g.) through the following Powershell script:

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

 

42 Comments


  1. I've seen this issue caused by turning off and on the publishing feature.

    Reply

  2. Hi Stefan Goßner,

    Did you mode Webs or publishing pages between webs?

    Reply

  3. Hi Mike,

    I tried that as well – but in my tests this did not lead to an inconsistency.

    Did you do anything specific in addition?

    Cheers,

    Stefan

    Reply

  4. Hi André,

    moving of sites should not be able to cause such problems as it only changes the Url property of the SPWeb object.

    Moving a page is actually an export/import of the page – and that will also not update a property of an SPWeb object.

    Cheers,

    Stefan

    Reply

  5. Hi Stefan,

    We had this problem a few months ago, but I forget the exact sequence of events. I could replicate it at the time, I think by switching off the publishing  feature on a sub-site, then on the site collection. Then turning it on for the site collection and then the sub-site.

    We didn't find a fix, and because of a deadline we just restored a backup.

    Reply

  6. Hi Mike,

    thanks for the hint!

    I tried your repro steps on my box but I cannot reproduce the problem.

    If you manage to find the exact repro steps please post them here.

    Cheers,

    Stefan

    Reply

  7. Hi Stefan, i know about the url Path reference to page layout  problem that also exist in 2007, but if you make the move of that page with the correction of the url  the field "__PagesListId" is not updated to the Pages folder.

    Reply

  8. This happen to me once when i migrate Publishing page between Webs in SharePoint 2010, after migrate and update the publishing reference to page layout, have the same error as yours, so after migrate needed to update this 2 field the page folder "__PagesListId" and Page layout url reference, in 2007 use blog.falchionconsulting.com/…/fix-publishing-pages-page-layout-url now change in the metadata list.

    Reply

  9. Hi André,

    thanks for the info.

    If I remember right that was related to combining backup/restore between farms (or renaming servers) and export/import.

    That was fixed long ago and people use the unsupported STSADM extension command to mangle with the links of the page layouts.

    Would be interesting to know if all affected users used this stsadm extension.

    Cheers,

    Stefan

    Reply

  10. Hi Stefan!

    I tried enable/disable of the feature from both the site collection and web site levels with no luck.

    I thne tried your code and BAM! it worked.

    Thanks for the fix.

    Reply

  11. Hi Peter,

    thanks for letting me know hat it helped!

    🙂

    Cheers,

    Stefan

    Reply

  12. Hi Stefan,

    this issue I faced with some sites and while deactivating and activating the publishing feature -is publisher causing the issue ?

    the script helped big time – thanks

    Gaadda

    Reply

  13. Hi Gaadda,

    I still don't have a repro for this.

    If you can share the steps then I can test.

    Cheers,

    Stefan

    Reply

  14. Hi Stefan,

    I have this same problem currently on one of my subsites. We had problems with publishing that I corrected at the Top Level site… but the subsites are still getting this error.

    Do I have to run this script at the top level? and will it trickle down to all subsites?

    Thanks!

    Martin

    Reply

  15. Hi Martin, this fix has to be done on each affected site (SPWeb object). You cannot fix it in one place for the whole site collection.

    Reply

  16. Hi Stefan

    Thanks for the pwer shell command. I store the pages which are derrived from page layout in document library other than pages library which is OOTB. My preoblem is when i try to edit page it gives me error. Invalid splistitem that is not compatible to publishing page layout.

    Thanks in advance

    Reply

  17. Hi Jagmohan,

    this is unsupported and cannot work. Either store them in a Pages library in a different site or in a folder in the Pages library. Only one library supporting Publishing pages can exist per site.

    Cheers,

    Stefan

    Reply

  18. Hi Stefan,

    I get this error when I run the command:

    PS C:UsersSPFARM> $web = get-spweb "2test.nl/…/Fase 2"

    PS C:UsersSPFARM> $correctId = $web.Lists["Pages"].ID

    PS C:UsersSPFARM> $web.AllProperties["__PagesListId"] = $correctId.ToString()

    PS C:UsersSPFARM> $web.AllProperties["__PagesListId"] = $correctId.ToString()

    You cannot call a method on a null-valued expression.

    At line:1 char:58

    + $web.AllProperties["__PagesListId"] = $correctId.ToString <<<< ()

       + CategoryInfo          : InvalidOperation: (ToString:String) [], RuntimeException

       + FullyQualifiedErrorId : InvokeMethodOnNull

    Any idea are welcome

    Kind regards

    Baldo

    Reply

  19. Hi Baldo,

    the error most likely means that $web is null – means get-spweb did not return anything.

    So either the url provided is not correct – or the current user does not have rights on this Url.

    Cheers,

    Stefan

    Reply

  20. Ah! Wait – it could be that $correctId is null. That is another possible reason for the problem.

    That would mean that there is no "Pages" library in this site.

    Please double check. In some languages the pages library has a different name – so you might have to adjust it.

    Cheers,

    Stefan

    Reply

  21. Hi Stefan,

    You are right the pages are in Dutch, could you tell me which parameter I should adjust?

    Thanks a lot in advance

    Cheers

    Baldo

    Reply

  22. Hi Baldo,

    what is the name of the library which holds the publishing pages in your Dutch sites?

    Cheers,

    Stefan

    Reply

  23. I'm experiencing the same issue and this fix works perfectly!  Thank you!  

    Now the question is, its happening to the thousands of sites I migrated from MOSS to SP2010.  Does anyone know if this issue be fixed in a next patch for SharePoint 2010?

    Reply

  24. This is awesome article. It helped me in solving one of major issues. Thanks!

    Reply

  25. When i try to run the scrip i'm getting the below error

    You cannot call a method on a null-valued expression.

    At line:1 char:58

    + $web.AllProperties["__PagesListId"] = $correctId.ToString <<<< ()

       + CategoryInfo          : InvalidOperation: (ToString:String) [], RuntimeException

       + FullyQualifiedErrorId : InvokeMethodOnNull

    Can you please suggest..

    Reply

  26. Hi Sidd,

    sounds as if $correctId is null.

    Is there a library named "Pages" in your site?

    In some languages the library has a different Name. E.g. in German it would be "Seiten".

    Cheers,

    Stefan

    Reply

  27. There is no page library created and I aslo confirmed there is no page library in any other language. I also noticed if I go to any other sub site I'm able to see the Page Library however it's not present on the problematic site.

    Reply

  28. Hi Sidd,

    if there is no Pages library, then it does not seem to be a Publishing site.

    Is the Publishing Feature enabled on the problematic site?

    Cheers,

    Stefan

    Reply

  29. This error occurred for me when we backed up a Site Collection and then restored to a new site collection as a subsite!

    Sadly your fix didn't work for me 🙁

    Reply

  30. How did you get the 'get-spweb' cmdlet excecuted on MOSS2007?

    I've loaded 'Microsoft.SharePoint.dll' in powershell but the 'get-spweb'-cmdlet is not recognised as a valid cmdlet.

    Reply

  31. Hi Bart,

    MOSS 2007 does not have native Powershell support. So this CMDLet does not exist there.

    The script works on SP2010.

    In MOSS 2007 I would recommend a C# script for this.

    Cheers,

    Stefan

    Reply

  32. Fix worked great for me. I had customized some subsites quite a bit and then used Powershell to copy them and got that stupid error. Prevented me from checking anything in unless i was in the library view. Applied the fix and i was able to check in from the home page.

    Thanks!

    Reply

  33. Worked like a miracle…Thanks…!!!

    Reply

  34. Hi Stefan,

    Bingo!!!It Saved my Day…

    I have been through a lot of hit & trials to get rid of this issue.Its really pain full working with migration with publishing pages.

    Thanks a ton for sharing this.

    Regards,
    Rabi

    Reply

  35. To run it with MOSS 2007 replace the $web line with this $web = (New-Object Microsoft.SharePoint.SPSite("MY SP SITE PATH")).OpenWeb()

    Reply

  36. Hi Stefan, Thanks for your great information.

    Reply

  37. Hi Stefan, I know this is an old thread but I have repro steps for SP 2013 at the site collection level:

    1) Create a site collection with "Team Site template."
    2) Activate the "SharePoint Server Publishing Infrastructure" site collection feature.

    3) Add a site collection property with key "__PublishingFeatureActivated" and value "True." (This was done to get the Content and Structure reports/views to work).

    4) Attempt to access navigation settings for the site collection.
    Boom! "An unexpected error has occurred." ULS complains: "The site is not valid. The ‘Pages’ document library is missing."

    Adding the __PagesListId property at the site collection level resolved it for me, but now I’m wondering what other domino effect impacts might be lurking after adding these two properties….

    BTW, I used the PropertyBagSettings2013.wsp solution, available here:
    http://pbs2013.codeplex.com/ to add/manage the properties.

    Reply

  38. Hi jkmuehlenbein,

    from the steps above it looks you did some unsupported steps.

    The publishing features set has a site collection feature (SharePoint Server Publishing Infrastructure) and a site feature (SharePoint Server Publishing).
    With step 3) you fooled SharePoint into thinking that the site feature "SharePoint Server Publishing" has been activated on the team site – but that is not the case.
    The correct method would be to actually enable the publishing feature on the site rather than just setting the __PublishingFeatureActivated property.

    The rest is a follow up problem. As you told SharePoint that the publishing feature is activated on the team site it expects a Pages library and a _PagesListId property.

    Cheers,
    Stefan

    Reply

  39. Deactivating and activating the publishing feature at site collection level would cause this issue.

    Reply

  40. Thank you. This worked like charm.

    Reply

  41. I got this issue while migrating publishing pages in different web apps.The fix works like charm.
    Thank You.

    Reply

Leave a Reply to Chris Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.