Skip to content

Kirby 3.9.8

$page->duplicate()

Duplicates the page with the given slug and optionally copies all files

$page->duplicate(?string $slug = null, array $options = [ ]): Kirby\Cms\Page

Parameters

Name Type Default
$slug string|null null
$options array [ ]

Return type

Kirby\Cms\Page

Parent class

Kirby\Cms\Page

The $options parameter

Name Type
title string
children bool
files bool

Example

$duplicate = $page->duplicate(
    $page->slug() . '-copy',
    [
        'title'    => 'New title',
        'children' => true, // duplicate with children
        'files'    => true, // duplicate with files
    ],
);

Duplicates are always created as draft pages.