Page Name vs Page Title

Hi there

I use a macro to retrieve the name/title of a page like this

$services.rendering.escape($xwiki.getDocument($xx).getDocumentReference().getParent().getName(), $doc.syntax)

I noticed that the name generated by the line above does not match the name in the navigation tree …

As far as I can tell, there is a difference in the page title vs the page name in xWiki. If I only change the title using the “Edit” mode of the page then there will be a difference from macro vs nav tree. If I use the “Rename” function, they will match …

This is on xWiki 12.5.1 using the traditional edit mode (not the inplace one)

Any idea? I time permits, I’ll upgrade to version 13 to validate this against the latest build, but I don’t know when this will happen …

Yes, it has been like this since the beginning. See Page Editing (XWiki.org) . In short:

  • page name is used in the page reference (technical, used in code) and page URL
  • page title is used whenever we display / list the page in the UI

Yes, because the navigation tree displays the title. We only display the page title in the UI, not it’s name. But sure, the page name can be the same as the page title, but it’s no necessarily the case.

Thank you @mflorea for the swift reply.

Didn’t come across this part of the page referenced above. Well, renaming the page will also alter the title, but not vice versa, which is a bit odd.

For my macro I would then get the name to construct the URL and the page title to display the link text (this is what probably the nav tree does, I assume?) …

Precisely, using the available API of course:

## For nested pages
#set ($parentReference = $docReference.parent)
#set ($parentDoc = $xwiki.getDocument($parentReference))
$parentDoc.url and $doc.plainTitle