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()


Comments (42)

  1. mike says:

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

  2. André Lage says:

    Hi Stefan Goßner,

    Did you mode Webs or publishing pages between webs?

  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?



  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.



  5. mike says:

    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.

  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.



  7. André Lage says:

    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.

  8. André Lage says:

    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…/fix-publishing-pages-page-layout-url now change in the metadata list.

  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.



  10. Peter says:

    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.

  11. Hi Peter,

    thanks for letting me know hat it helped!




  12. says:

    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


  13. Hi Gaadda,

    I still don't have a repro for this.

    If you can share the steps then I can test.



  14. says:

    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?



  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.

  16. Jagmohan says:

    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

  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.



  18. says:

    Hi Stefan,

    I get this error when I run the command:

    PS C:UsersSPFARM> $web = get-spweb "…/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


  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.



  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.



  21. says:

    Hi Stefan,

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

    Thanks a lot in advance



  22. Hi Baldo,

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



  23. davisonline11 says:

    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?

  24. S.Bahree says:

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

  25. Sidd says:

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

  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".



  27. Sidd says:

    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.

  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?



  29. Dawn says:

    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 🙁

  30. Hi Dawn,

    backup and restore cannot do what you described.

    Or did you mean Export/Import rather than Backup/Restore?

    Then see here:…/limitations-of-stsadm-o-export-import-related-to-publishing-sites.aspx



  31. Bart says:

    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.

  32. 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.



  33. Rube says:

    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.


  34. Sufal Lakra says:

    Worked like a miracle…Thanks…!!!

  35. Rabi Kumar says:

    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.


  36. Chris says:

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

  37. karthik says:

    Hi Stefan, Thanks for your great information.

  38. jkmuehlenbein says:

    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: to add/manage the properties.

  39. 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.


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

  41. Pratik M says:

    Thank you. This worked like charm.

  42. Rabi Kumar says:

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

    Thank You.