Introduction
SharePoint modern site pages are converted to News when they are promoted. Only the Promoted site pages will be displayed as News in SharePoint Out of the Box webparts. It clearly states that both the Site Pages and the News will be maintained in the same page library.
Please take a look at my previous article on create modern pages using PnP JS in SharePoint Online. Here we are going to see how to add the custom field properties only to Site News and hide it for Site Pages. Let’s see the step-by-step implementation for this.
Step 1. Go to the below URL for your site to create a content type.
{siteURl}/_layouts/15/ctypenew.aspx
Step 2. Let’s give a name to our new content type, “Site News” which is more meaningful. Set the parent content types as below “Document Content Types” and “Site Page”.
Even though we are creating news, the site page is the base, so we are selecting the parent content type like this. So, it will inherit all the site page-related fields.
Click the OK button at the bottom.
Step 3. Now add the columns you required only for News from Site Columns or create a new column using the below options.
Here, for example, I have created a column called “News Category”.
Step 4. Now go to the Site Pages using the URL below and go to the “Library settings” using the Gear Icon at the top right in the O365 banner.
{YourSiteUrl}/SitePages
Step 5. By default adding content types will be enabled on the Site Pages so look for the link “Add from existing site content types” and click that.
Step 6. In the next screen, add the “Site News” content type that we created in Step 2 and click the OK button at the bottom. Now you can see your content type and the column added in it should have been added to the Site Pages.
Step 7. Now go to Site Pages again and click the New Button at the top in the command bar, you can find the new content type listed.
Step 8. Create a site page using this new option -- now you will get the custom property enabled only for News, not for the site page.
Below is the screenshot for the Site Page published as News with only News related properties,
Below is the screenshot for the Site Page without any news-related properties.
Creating Modern Page Templates in SharePoint Online
We have controlled the properties when it is directly created from SitePages, but how do we achieve that when pages are created using Out of the Box options? News can be created using News Webpart, or it can be created from any existing site pages using the “+ New” button at the command bar.
Here is a solution for that as well, we can use the Page template feature.
Step 1. Go to the news page that you created by using the new content type. Click the “Edit” button in the top right of the command bar.
Step 2. In the top left of the command bar click the arrow near “Save as template” like below.
Step 3. Now your page will be converted to a template mode, give the title of the template and save the template.
Note. You can use this template option to predefine the page design like author, webparts. So, you can also maintain even sitepages across your site with same template.
Step 4. You can find the created templates in SitePages under templates folder, you can go to that templates folder using below url also.
{YourSiteUrl}/SitePages/templates
Step 5. Now, create news from any of the out of the box options. You can see the template created in Step 3. Choose that template and create news, it will be configured by default with the news related properties.
We are done with the modern page template with the field properties only applied for that template.
Conclusion
I hope this article helps you to understand how to enable the custom page property fields only for SharePoint News and not for normal Site Pages. If you have any questions/issues about this article, please let me know in the comments.