Monday, February 18, 2013

SharePoint 2010 add Site Pages to your site

Ever wondered why some sites have a Site Pages library and a Site Assets library some don't?

The answer lies in a feature called Wiki Page Home Page, which is enabled by default for Team Sites in SharePoint 2010. However, other types of site templates may not activate that feature by default, and if that’s the case, those libraries won’t be there.

If you need them, you have a few options:

EASIEST BUT CHANGES YOUR HOME PAGE: Activate the “Wiki Page Home Page” feature. The feature will create those libraries and will also create a wiki page and set it as the home (welcome) page for your site.

BETTER WAY: If you only need the libraries and don’t want your home page changed, you can have SharePoint Designer 2010 create the libraries for you: Open SharePoint Designer. In the “Site Objects” pane on the left, click “Site Pages.” SP Designer will load the contents of the Site Pages library and tell you it’s empty. However, it also creates the Site Pages library for you in the process. Do the same thing for “Site Assets” (also in the Site Objects pane).

PROGRAMMATIC CHECKS: If you have code that depends on the existence of these libraries (such as a feature receiver), you can use two methods on the SPListCollection class to ensure the libraries are there: EnsureSitePagesLibrary() EnsureSiteAssetsLibrary()