Summary: Move and copy wiki pages
Version: 20180225
Prerequisites: PmWiki 2.2.x
Status: production
Maintainer: Petko (original author: Eemeli Aro)
Discussion: MovePage-Talk
Download: movepage.phpΔ


MovePage provides a simple form and simple actions to copy or move/rename a page within a wiki. It creates a redirect to the new page at the old page.

To use, once installed, add ?action=copy or ?action=move or ?action=rename to a page's location (or use a PageActions link, if you've defined one) to get a simple form, fill in the target name and press a button ("Copy" or "Move" or '"Rename"). MovePage will verify that the target page doesn't already exist, and that you have the required permissions, then moves or copies or renames the page including all of its history, as well as adding a note in the page history & recent changes that the copy/move/rename has been made.


  • Download movepage.phpΔ to your cookbook directory
  • Add the following to your config file:
    if (($action=='copy') || ($action=='move') || ($action=='rename')) include_once("$FarmD/cookbook/movepage.php");
  • Optionally, add something like the following to your Site.PageActions page:
    (:if auth edit:)
    * %item rel=nofollow class=move% [[{*$FullName}?action=move | $[Copy/move] ]]


MovePage is configured via an array $MovePageFmt, which contains the following entries. These are all interpreted in the context of the source page, hence the use of a new page variable {$MoveTargetName}.

default 'Page copied to {$MoveTargetName} from {$FullName}'
The change summary to leave on a copied target page.
default 'Page moved to {$MoveTargetName} from {$FullName}'
The change summary to leave on a moved target page.
default 'Page renamed to {$MoveTargetName} from {$FullName}'
The change summary to leave on a renamed target page.
default 'Page moved to {$MoveTargetName}'
The change summary to leave on a moved source page, if it is not deleted.
default '(:redirect {$MoveTargetName}:)'
The text to leave on a moved source page. Use $MovePageFmt['old-text'] = 'delete'; to delete the source page when moving.
The form used to copy or move a page. See the source for the default value or below for an equivalent in wiki markup.

Custom copy/move form

To modify the form used, you'll need to define your own form as a wiki page, such as Site.MoveForm and then set the following in a config file:

$MovePageFmt['form'] = 'wiki:Site.MoveForm';

Here's how to re-implement the default form using wiki markup:

!! %block wikiaction% $[Copy/move] {*$FullName} $[to:]
(:input form "{*$PageUrl}?action=move" post:)
(:input hidden action move:)
(:input hidden n {*$FullName}:)
(:input text to {*$MoveTargetName}:)
(:input submit copy $[Copy]:)
(:input submit move $[Move]:)
(:input submit rename $[Rename]:)
(:input submit cancel $[Cancel]:)
(:input end:)

Copy/move Cookbook.MovePage to:


If you want, you can use MovePage's actions from another recipe or form by POSTing to a location such as {$PageUrl}?action=copy or {$PageUrl}?action=move with a single POST parameter to=New.Name. to as a GET parameter is explicitly not handled, as that might result more easily in accidental use.

RenamePage has done pretty much this since 2005, but it's broken enough things on my sites for me to have disabled it. I also couldn't be bothered to look through its code to figure out all that it does.

Release notes

  • 20180225Δ: This version allows to pre-fill the new page name field if there is a "&to=Group.Page" string in the "?action=move" URL.
  • 20171206Δ: add default_action class, $MovePageDefaultAction, $MovePageSetDefaultActionFromPageAction, see Talk page (Said Achmiz)
  • 20171121: Revert back to using array() construct, for compatibility with PHP 5.3 and earlier. Make title tooltips translatable. Fix bug with international page names when UTF-8 is enabled. Remove unneeded updating of $LastModFile, already done in WritePage. Remove unneeded auth prompt when renaming. Move warnings/messages above form, not after it. Add hidden form element with the action for the POST array (on some installations the GET element may be lost). (Petko)
  • 2017-11-20Δ: added 'rename' action to move without leaving a redirect (Said Achmiz)
  • 2009-08-17Δ: first release (Eemeli Aro)

See also



This space is for User-contributed commentary and notes. Please include your name and a date (eg 2007-05-19) along with your comment. Please leave new comments at the top of this section.

It seems this line is not necessary, since most Page Manipulation routine is handles UTF-8 encoded path w/o problem. I can't rename a page into a 'Chinese file name' unless I comment out this line.

   if (preg_match('/[\\x80-\\xbf]/', $tgtname)) $tgtname = utf8_decode($tgtname);

This was fixed in 20171121. --Petko November 21, 2017, at 02:07 AM

I have some problems with Pagelists and Conditions

I installed the Cookbook Cookbook.MovePage. As soon a page ist moved from the Group e.g. "Shows" to "Showsarchive" it still exists in the group "Shows". Therefore I want to give out all the "Shows.*" pages in a pagelists but not showing the pages that are already in the group "Showsarchive.*".

It should be a conditions something like this:

(:pagelist group="Shows" fmt="#simple" if="!group Showsarchive.*" :)

But i have not clue and invested already hours in finding out. Maybe you can help me? That would save my day! Jean Baptiste On May 24, 2010 - at 13:28 PM

I just found out, Yeah:

(:pagelist group="Shows" fmt="#simple" if="!exists Showsarchive.{=$Name}" :)

Jean Baptiste On May 26, 2010 - at 1:13 AM

Are you sure you're moving these pages instead of copying them? Moving should remove the page from the original group; if that's not happening then there's a bug. However, if you're copying pages then your solution is a good one. —Eemeli Aro
My experience was that "move" changes the original to redirect to the new page - but the original still exists. If it didn't do that, links to the original would be broken - so for some installations that might not be a bug. However, if you need to be able to test whether the original is redirecting, perhaps the recipe can be modified to include on the original page a page text variable such as "moved: newname" - then moved pages can be tested by a conditional. - RandyB May 26, 2010, at 12:56 PM

Jazzvox on Dec 07, 2011 - at 11:55 CET

Use CleanUp in addition, or delete moved pages manually. It's the way it should be.

User notes +7: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.