In this article, you will learn how to deploy a page layout, using PnP Client Side Object Model code.
The page layout can be created manually in many ways. The page layouts can be deployed manually or using the deployment tools built , using programming languages. Here, let us see how the page layouts can be deployed, using PnP CSOM programming language.
If you are new to PnP programming, please refer to the ebook on PnP CSOM programming, which has the introduction, basics and samples on PnP CSOM programming.
Microsoft Visual Studio
SharePoint Online portal
Page layouts can be of multiple types. They are article pages, publishing pages, welcome pages etc. Each of the page layouts are associated with a content type. All the page layouts are differentiated, using content type id. The screen shot given below shows the page of the available content types (Content types page - /_layouts/15/mngctype.aspx).
Custom page layouts can be built, using the existing content types. These existing content types are called as associated content types, while creating a custom page layout.
Create a page layout manually, using the editors or modify the existing page layout by downloading from the site.
Create a new console Application and install the packages required for PnP CSOM programming, using NuGet Package Manager. (The detailed steps to create a project has been explained in the ebook mentioned above).
Create the layout, using DeployPageLayout command. The required input parameters are source file path, title, description, associate content type id.
The content type ID of the page layouts can be identified from the content type page (/_layouts/15/mngctype.aspx). For example, to get the content type ID of article page layout, click the article page content type. The ID can be extracted from the URL (ctype parameter).