0

If I have an existing page in the site pages library. How can I change the headerlayout type to colorblock? It seems I can specify that when making the page through pnp provisioning or

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpclientsidepage?view=sharepoint-ps

But for an existing page, there doesn't seem to be a command.

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnpclientsidepage?view=sharepoint-ps

Does anyone know?

2 Answers 2

0

You can achieve this in SPFx Web Part. `const file = await sp.web.getFileByServerRelativeUrl(this.newPageServerRelativeURL);

                    const page = await ClientsidePageFromFile(file);
                    
                    page["json"].CanvasContent1 = "<div></ div>";
                    page["json"].PageLayoutType = "Article";
                    page["json"].BannerImageUrl = "/_layouts/15/images/sitepagethumbnail.png";
                    page["json"].PromotedState = 0;
                    page["_layoutPart"].properties["authors"] = this._Authors;
                    page["_layoutPart"].properties["layoutType"] = "FullWidthImage";//"ColorBlock";//"NoImage";
                    await page.save();`
-1

You do not need to set the SharePoint modern page Header Layouts to the Color block layout by using PowerShell command.

SharePoint Online meets your needs with out-of-the-box UI design.

Please follow steps:

1.Create new page.

When the mouse hovers over the Title area, click on Edit web part button. Here are a variety of Layout options for you. enter image description here

2.Click the Colorblock option and publish your page. enter image description here

1
  • I know I can do that, but I'm looking for a code approach here.
    – omega
    Dec 4, 2020 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.