I have come across a business requirement, while implementing this I need to get publishing site page layout on sharepoint 2010 using server object model.

After a little research I managed to do this, I think it is worth to share code with you guys.

The code below was used to get the default page layout of a publishing web site in SharePoint 2010.

private static void GetPageLayout()
using (SPSite site = new SPSite("Publishing Site Collection URL"))
using (SPWeb web = site.OpenWeb())
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
PageLayout pageLayout = publishingWeb.DefaultPageLayout;
Console.WriteLine("Layout Name: "+pageLayout.Name + " Site URL: " + pageLayout.ServerRelativeUrl);


About Us

Follow Us

Email: contact@keapoint.com
Phone:  0208 7852 888

Registered Address: 1 Amber Close, Reading, RG6 7ED. United Kingdom

Company No. 11586817