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.
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.