Skip to content

Kirby 4.1.0

$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

This method does not modify the existing $page object but returns a new object with the changes applied. Learn more →

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.