Short description
When you rename a page it would be good if moinmoin went through and updated the Wiki links of any page that linked to the old name and changed to the new name to avoid broken links.
See SearchAndReplace for (future) fix to this problem.
Problems:
- Other pages that contain the links might be edited in the same time by other users. Editing those pages by the wiki will give them an error message when they try to save their edits. But this is not a big problem, as the edit conflict is very small, and easy to work with.
To avoid this problem, we need a kind of deferred edit system, that will allow you to add an edit to a page, like "replace links to ThisName with links to ThatName", and let the wiki apply the change when the page is available for editing, for example, when the edit lock is released. This might work for simple edits like this, in the worst case, the edit can't be applied because the text is not there any more.
In the case when you want to keep the old name, for example to prevent broken outside links, don't rename the page, but create a new page with the page content, and convert the old page to a redirect page to the new page. This will keep all existing links working. You might not want to do this if the old name should not be in the wiki or you would like to use it for another content.
I think automatically changing all pages that link to the current page is risky and not worth the complication. Automatically replacing the old page's name with a #REDIRECT to the new page, however, is a great idea. I would like there to be a check box when you rename the page "Replace old page with redirect to new page". It could be configurable at the wiki level whether this check box is selected or clear by default. I often rename a page and then manually recreate the old page with a redirect to the new page if I'm reorganizing/cleaning up/consolidating some pages. -- DavidCramer 2005-07-10 23:03:39
What if you want to use the old name for a new page? redirect is not a real solution that works for all cases.
- It is. Maybe read this page completely.
No, not even close. If you rename page A to B, and A now redirects to B, that's fine--pages linking to A will go to B. But now you replace A (the redirect) with new content, and now links to A that should be getting through to page B will go to the new page A instead. Intent broken. This is wrong. The redirect solution is a crude hack that seems attractive because the ideal solution is not simple to implement. Not saying it's an inappropriate hack, necessarily, but it can't be passed off as a real solution, IMO. -- SteveDavison 2007-08-10 05:55:20
How others solve this problem
Mediawiki simply creates a page that redirects. Additionally, this rule applies: When you rename a page, you can rename it if the target page does not exist or if it just contains one revision and a redirect. This solution is somewhat magic, but intuitive in most cases and keeps the wiki intact.
To automatically create redirect pages is often plain stupid (IMHO). Often renames happen because users accidentally created pages with typos in their name - you don't want a redirect from the pagename-with-typo to the pagename-without-typo. Deleting the automatically created redirect page is also no good, because the first revision will stay there forever. Thus we prefer to manually create the redirect pages, IF NEEDED. -- ThomasWaldmann 2009-11-19 14:14:50
ikiwiki updates links by default when renaming pages/subpages. It works great, never had a problem with it. Seems like a fairly trivial feature to implement, unless I'm missing some technical point-- EricDrechsel 2009-11-19
I don't know ikiwiki at all, neither their implementation, thus it is hard to comment that. If they maybe just have one markup parser, rather simple link syntax, no code/verbatim sections, replacing by simple search-and-replace can work. Note that all this is not the case for moin. -- ThomasWaldmann 2009-11-19 14:14:50
Redirecting after Renaming in MoinMoin
A way to do this in MoinMoin is to modify the "PageEditor.py" by hand as follows:
I added a new Function "redirectToNewPage":
def redirectToNewPage(self, oldpath, newpath, newpagename): try: import shutil shutil.copytree(newpath, oldpath) self.saveText("#REDIRECT " + newpagename, 0) return True, None except: return False, self._('Error occured in attempt to recreate old article with rediretion to new article.')
and called it in "renamePage" at the very end of the try-block, but before the return occurs of course:
self.redirectToNewPage(oldpath, newpath, newpagename)
-- ChristianHoffmann 2007-08-14 12:25:26
Twiki does the search and gives the user an option on making the edit on each other topic individually. My success has been less than desirable at gettings those edits done automatically, even when the page isn't being edited.
UseMod does this, but I do not know how they solve the edit conflict. Ant the feature seems to be buggy.
Comment: Automatic change would be great, but all this looks like a big discussion, however:
- how about showing the user who renamed the page (after the renaming occured) which pages still link to the old page. Just like it is done when you create a new page, all pages with simmilar name are presented.
- another solution: Instead of changing the links of a page in edit mode immediately, moinmoin could wait until the user finished editing and changing the links thereafter. This would mean that every page which is edited currently gets a small journal. If the links of the page should be replaced the modifications are put into the journal first. After the user finished editing the page, the journal is executed and all links which shall be modified in the edited page are renamed.
Comment: Sometimes you rename a page because you immediatly like to add a new page with the previous used name. So it could be difficult to rename links much later. MoinMoin knows which pages were currently edited and it knows which pages do have links which needs renamed. If pages with links not edited currently there links could be renamed directly. The ones who are edited should be changed after the time limit is over for editing or probably if the user selects preview.
Comment: How about a command line util which checks if the wiki is down and then renames the pages in one batch? I understand that this solution might be less than perfect but it would solve the synchronization problem. -- A. Digulla 25.1.2005
Comment: Probably not compatible with MoinMoin internals - but how about solving this by changing the way pages are referenced internally? Instead of referencing pages by name, reference them by a unique internal ID and store the page name in an internal field inside the page or in a separate lookup table. Have MoinMoin handle the translation of IDs to names (when the page is being displayed and edited) and back (when an edited page is being stored). In this way, renaming a page only involves editing one atomic edit in one single location. If I was going to write a Wiki from scratch, I would write it like this.
Comment: We need a solution which will work with acl pages too.
Comment:We moved from Mediawiki to MoinMoin and we miss this feature really, it should work as implented in Mediawiki
Comment: In a similar vein... An even bigger problem with rename is that it does not bring all of your page's children along with it. Most of the time you would want to keep your tree together, and it's terrible to have to rename 20 some pages individually to work aroun this. Then do you really want a whole tree of redirects?? Treating pages hierarchically is much more intuitive. -- SteveDavison 2007-08-10 05:55:20
Agree with SteveDavison, i want Hierachical Renaming made possible, Thanks! Time
The part of hierarchical renaming is implemented in 1.6 -- ReimarBauer 2007-10-06 07:38:56
Use the Include feature
A cheap solution to page renaming is just to include the old wiki page in an Include statement within the new page, like this:
[[Include(OldPageName)]]
where OldPageName is the name of the page you want to rename.
A page with list of redirect pages
What about having a page, which contains a list of source and target "redirect". It could even allow regexp. For example :
# Some redirect OldPageName :: NewPageName Fruit(.*) :: Fruits/$1 # those redirect should be deleted after 2009-12-31 (old transition pages) Vegetalbes :: Vegetables # Some alias for French Legumes :: Vegetables
This solution would be easy to administer. It would be possible to identify broken redirect.
Optionally, This page could be automatically populated when a page is renamed.
the mediawiki suggestion to automatically create a redirect page sounds not too bad. and it seems extensible, and maintainable, one could have to functions:
- rename: move page + create a redirect page
- fix links to redirects: maintenance function which corrects links to redirects by pointing them to the redirect target instead, leaving the displayed text intact. it might be called when a redirect is deleted, or out of a maintenace window.
-- ThurnerRupert 2009-02-21 11:27:20
For some cases it is not bad, for others, it is. If you rename some page that (for quite a while) had a good other page name and was popularly linked from other pages or the outside, a redirect is maybe what you want. OTOH, many users are not careful when creating pages and do typos in the pagename and 1 minute later rename the page to the real name (hopefully). That is the reason why you don't want to have redirect pages created automatically for rename. -- ThomasWaldmann 2009-02-21 16:48:41
: would it be possible to have an option to not create it? personally i create 5 to 10 pages with a correct page name for one with a typo. the same with renames. so the software is made for 10% of the cases. the much more important feature would be the "fix links to redirects". this would allow to reorganize wikis efficiently. our use case: the debian wiki want to change the internationalization scheme. and needs renames. but too many pages get inconsistent. -- ThurnerRupert 2009-02-21 18:07:58
- Pages really should be referenced internally by ID rather than directly by name. This has many benefits beyond making this problem easier, E.G. internationalization, aliases, probably more....
- Rather than argue about how to make rename do different jobs, lets make multiple commands for all these different jobs. EG, simple rename, rename + heirarchy + update links, rename + redirect etc...
--DylanMartin 2009-06-02
Dylan, how would your wiki links look like when using an ID for pages internally?