Create a page with the native API

Use this procedure and the code sample to create pages via the native Sitefinity CMS API.

When creating a page, you must perform the following:

  1. Get an instance of the PageManager.
    Pages in Sitefinity CMS are managed by the PageManager class, therefore, you need to get an instance of it.
  2. Set the parent of the page.
    When creating new page, you must specify the parent page. If you do not have parent node, you must use the frontend root node when the page is a frontend page and the backend root node when the page is a backend page.

    You use SiteInitializer to get the IDs of the root nodes.

  3. Create the page.
    To create a new page, you must use the CreatePage method of the PageManager. If the page does not exist, you create a new page with the specified ID and parent. The method requires as arguments the parent, the page ID, and the page type.
  4. Set the page properties.
    When creating a new page, we recommend to set at least the following properties:
    • Properties of the page node:
      • Title
      • Name
      • Description
      • UrlName
      • ShowInNavigation
      • Crawlable
      • RequireSsl
    • Properties of the page data:
      • Title
      • HtmlTitle
      • Description
  5. Publish the page
    To publish your page you need to set the ApprovalWorkflowStatus property of the page node to Published.
    Pages can have the following workflow statuses defined by the 
    ApprovalWorkflowState property
    • Published
    • Draft
    • AwaitingApproval
    • AwaitingPublishing
    • Rejected
  6. If required, set the page as home page.
    After you create the page, if it is the initial page of your website, you must set it as home page.
  7. Save the changes.
    Save all changes that you have made to the page using the SaveChanges method of the PageManager.

EXAMPLE: In the following code example, the CreatePageNativeAPI method create a new standard, empty, frontend page:

NOTE: In the code example above the ID argument is assigned to the master version of the page.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?