Forum Discussion

irshad313's avatar
irshad313
Copper Contributor
Feb 07, 2024

Publishing a page template

I created a page template in one of the site and distributed that page template to all the active communication sites through powershell [as a page template]. but the issue is minor version of a template has been created i need to publish a major version of the template for all active sites, what should be the ideal way to achieve this.

 

how to publish major version of a page template through powershell.

 

Thanks,

Irshad

  • Thanks for replies, I have achieved my objective with this scripts
    $sites = Get-PnPTenantSite -Template SITEPAGEPUBLISHING#0
    foreach($site in $sites)
    {
    Connect-PnPOnline -Url $site.Url -Interactive
    Set-PnPPage -Identity “Templates/Page-From-TemplateTest.aspx” -Publish
    }
  • irshad313 

     

    If you are using PnP PowerShell, you can use the -Publish parameter with the Set-PnPPage cmdlet.

     

    Or you can try like mentioned here: Publish page using PnP.Powershell 

     

    Related read: Set a page template as default page template in SharePoint Online 


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • Are you sure you want to do this? By default, page templates stay in "minor version" mode so that they are only visible to editors and not readers. You still get the functionality of the template, but it remains in a "never published" state.
    • irshad313's avatar
      irshad313
      Copper Contributor
      Yes I want to publish this, because the requirement was to create a template based out of a Published templated [From other site]. I was able to copy templated from site to all other sites but those templates are not available for users to use because of the minor version.
  • irshad313's avatar
    irshad313
    Copper Contributor
    Thanks for replies, I have achieved my objective with this scripts
    $sites = Get-PnPTenantSite -Template SITEPAGEPUBLISHING#0
    foreach($site in $sites)
    {
    Connect-PnPOnline -Url $site.Url -Interactive
    Set-PnPPage -Identity “Templates/Page-From-TemplateTest.aspx” -Publish
    }

Resources