Pnpframework: Publishing a Page template

Created on 6 May 2021  路  5Comments  路  Source: pnp/pnpframework

Hi all,

I have an issue trying to publish a page template. I remember that a page template couldn't be published, I think that the option was even not appearing from interface. Furthermore, documentation says "Template pages are not published; only the pages created from the templates can be published."

I checked that the PnPFramework code has a condition to not publish the page template which makes sense according to the documentation.

// Publish page, page templates cannot be published
if (clientSidePage.Publish && !clientSidePage.PromoteAsTemplate)
{
page.Publish();
}

The thing is that now it's possible to publish a page template from the interface. Does this mean that the code should be changed? Or is there another reason why page templates are not published?

Thanks,

page transformation 馃 question

All 5 comments

@roberAlb : do you mean there's an option in the UI to publish a page template?

In my tenant I do not (yet) see that:
image

@jansenbe : not from the UI, but it's from the Site Pages library, for instance, this screenshot is from a template inside the Templates folder where the publish button is appearing and allowing you to publish the template

image

Let me check with the feature owners to see if "publishing" page templates is what was intended here. Thanks for bringing this up @roberAlb .

@roberAlb : I've checked things and the fact that you can publishing a page templates by going via the pages library is actually a bug...that also implies that from PnP code point of view we should not support publishing page templates.

@jansenbe I think being able to publish templates is fixing another issue that was caused by that situation before.
If you configure a Site Pages library with Approval and draft items visibility only to approvers and the author, this will prevent any other contributors in the library to be able to create pages from the existing templates as those will be draft and unless you are the template author you won't be able to see that when creating a page.
Are you 100% sure this is not intended update to how SharePoint manages the Templates?
image

Was this page helpful?
0 / 5 - 0 ratings