Skip to content

Kirby 4.1.2

$site->createChild()

Creates a main page

$site->createChild(array $props): Kirby\Cms\Page

Parameters

Name Type Default
$props * array

Return type

Kirby\Cms\Page

Parent class

Kirby\Cms\Site

Example

Programmatically create a new page as child of the $site object.

<?php

$kirby->impersonate('kirby');

$newPage = $site->createChild(
    [
        'slug'     => 'blog',
        'template' => 'blog',
        'isDraft'  => false,
        'content'  => [
            'title' => 'Blog',
        ]
    ]
);