Saturday, 19 January 2013

Missing SitePages in Personal Site

Lately I faced and issue while working with Personal Sites. My requirement was to deploy a page in personal sites everytime a personal site gets created. So, the quick solution that came to my mind was to deploy it using feature stapling, and everytime the personal site gets provisioned for somebody, the feature will get activated and my page will get deployed to the SitePages library in the personal site that gets created. To my utter surprise, there was no SitePages library in my personal site though it was present in the MySite host. Then I found out that "Wiki Page Home Page" feature , which activates by default for Team Sites ,do not get activated by default for certain site templates, including the personal sites. Therefore , personal sites do not contain SitePages library by default. In-case we want to create SitePages library in personal sites then in our feature activation we need to write the following line of code that ensures creation of the SitePages library.

SPList list = web.Lists.EnsureSitePagesLibrary();

And thats it. This will create SitePages library for a non team site. :)