Showing posts with label WikiPage. Show all posts
Showing posts with label WikiPage. Show all posts

Monday 27 August 2018

Provisioning Layout and Static Content for Office 365 SharePoint Wiki Pages Using PnP PowerShell

Here let us look how to add text to the wiki pages using text layouts with predefined text. In the samples, let us use PnP PowerShell scripts to create a wiki page, apply default layout and for adding content.

Problem Statement: Programmatically creating or updating wiki pages which uses OOB wiki page layouts with some predefined text. This is easily possible with manual actions. While creating a page using client side scripts, adding content to the page is not feasible. So, let us look how to add the text to the created wiki pages programmatically using PnP PowerShell scripts.


Applying Wiki Page Layouts with Content


The following are the points to be considered for adding text to wiki pages.
  • Create a Wiki Page (This is required if the page doesn’t exist already)
  • Retrieve the wiki page to be updated – Using CAML query to get the required page list item.
  • Apply text layout with predefined text to a retrieved wiki page.
Before getting into operations, let us connect to the SharePoint site using PnP PowerShell using the following snippet.

Create a wiki page: Let us programmatically add a page to a SharePoint site using PnP PowerShell script. The following snippet creates a page with the required layout.
Note: Skip the above step if wiki page is already created.