External content into Modern Page Template

Kennedy, Andrew 1 Reputation point
2021-08-30T15:49:49.697+00:00

Maybe not considered "external content", but I have a spreadsheet containing page content - page title, description, page body, etc. which I was planning to copy/paste into around 30 pages using the same template. There has to be a better way, right? :)

I am using a Modern page, with Modern web parts... so I hope this is still possible.

Andrew

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 44,311 Reputation points Microsoft Vendor
    2021-08-31T08:20:28.817+00:00

    @Kennedy, Andrew

    Based on your description, I understand that you want to create 30 modern pages with template based on a csv file.

    First, you could create a site template in the site pages library, then create a csv file to store the site collection information, after that, run following PowerShell to create 30 modern pages with template based on a csv file. But you cannot set description and page body for newly created modern pages, due to they are not available parameters of Set-PnPClientSidePage command.

    Connect-PnPOnline -Url "https://mytenant.sharepoint.com/sites/SiteName"  
      
    # load the CSV file into a variable for looping  
    $CSV = import-csv -Path 'C:\Users\RD\Desktop\Products.csv'  
      
    # set the path to my SharePoint sites Site Pages folder  
    $sitePath = '/sites/SiteName/SitePages/'  
      
    # load the page template we created earlier  
    $template = Get-PnPClientSidePage -Identity "Templates/Product-Template"  
      
    # loop over all the rows in the CSV file  
    foreach ($row in $CSV) {  
      
       # set the full file name from the FileTitle in the CSV and add .aspx  
       $fullFileName = $row.FileName + '.aspx'  
      
       # create a variable for the full path to the file  
       $fileURL = $sitePath + $fullFileName  
      
       # save a new SharePoint Page based on the Page Template we loaded earlier  
       $template.Save($fullFileName)  
      
       # run Set-PnPClientSidePage using the identity of the file we just saved to set the title and  
       # publish the page which is required before creating a navigation node  
       Set-PnPClientSidePage -Identity $fullFileName -Title $row.PageTitle -Publish  
      
       # add the page to the QuickLaunch navigation which is at the top of Communication sites  
       $nav = Add-PnPNavigationNode -Title $row.NavTitle -Url $fileURL -Location "QuickLaunch"  
    }  
    

    Reference:
    PowerShell: Create SharePoint Online pages from a template and add them to navigation

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.