3

we are trying to migrate classic pages to modern and it's a must to maintain the initial publishing date of the page. This date should be visible in the page header:

Required header date change

Digging around we found that there is "FirstPublishedDate" field which is read-only but it's possible to change the value as you can see in the image:

List fields

However, changing this field does not affect the displayed date in the header of the page.

So, I have two related questions:

  1. Where is the date of the page header stored?
  2. How could we change it?

Additional info:

  • We are using PnP-PowerShell to update the fields.
  • Also I found this post from user voice which is very disapointing to me.

Any help is appreciated.

1 Answer 1

0

This solution works on the Created (Created_x0020_Date) column in Modern SharePoint.

Screenshot from SharePoint Site Pages listing showing a page created in 1972

I'm using the PowerShell module in VS Code with PnP-PowerShell added from the command line - this is the easiest way I've found of doing it on a Mac.

First, connecting to the site:

$siteURL = "https://whatever.sharepoint.com/sites/sitename/"
Connect-PnPOnline -Url $siteURL -Interactive   

Set some variables to keep things clean and make the code more repeatable.

Use the page filename without the .aspx part, so article-from-1972.aspx becomes article-from-1972. For the date format, I'm using yyyy-mm-dd for clarity.

$pageTitle = "Page-name-without-aspx"
$newDate = "2022-01-31 00:00"  

Then three lines to get the page according to the title, set its date, and then republish.

$page = Get-PnPPage -Id $pageTitle 
Set-PnPListItem -Identity $page.PageId -List "Site Pages" -Values @{"Created"=$newDate}
$page.publish()

Hope this is of use to someone

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.