"display" Macro

Last modified by Lucas Charpentier on 2026/09/22 16:48

Reference

Description

The display macro shows another page inside the current one.

The displayed page is rendered in its own context, exactly as if you opened it directly: its relative references, its attachments in particular, are resolved from its own location and not from the page displaying it. InformationThe include macro on the opposite renders the target in the current page's context instead.

 

Usage

{{display reference="Sales.Reports.WebHome"/}}

The macro works inline as well as standalone.

Three behaviours are worth knowing before you use it:

  • displaying a page that does not exist renders nothing at all, rather than an error;
  • displaying a page you are not allowed to view raises a macro error;
  • a page cannot display itself, directly or through a chain of pages: the macro detects the recursion and refuses it.

The editors ask for the page to display, and offer the two optional parameters below it:

display-macro-wysiwyg.png

Parameters

NameMandatoryAllowed ValuesDefault ValueDescription
referenceyesan entity reference, such as Sales.Reports.WebHomenoneThe page to display. Either this parameter or page has to be set.WarningA dot that is part of a page name has to be escaped with a backslash, since a dot otherwise separates the parts of the reference.
pageyesa page reference, such as Sales/ReportsnoneThe page to display, written as a page reference instead of an entity reference. Either this parameter or reference has to be set.
typenoan entity typedocumentThe type of the entity reference points at.
sectionnoa heading id, such as HMyHeadingnoneDisplay only that section of the target page instead of the whole page.
excludeFirstHeadingnotrue or falsefalseLeave out the first heading of the displayed page or section, when it starts with one

Examples

Display a Page

{{display reference="Sales.Reports.WebHome"/}}

display-macro-rendered.png

Display a Page of Another Wiki

Prefix the reference with the name of the wiki:

{{display reference="intranet:Sales.Reports.WebHome"/}}

Display a Single Section

The section parameter takes the id of a heading, which XWiki generates from the heading's title. For a title made only of the characters A-Z, a-z, 0-9, :, _, . and -, that id is H followed by the title with its spaces removed: "My Heading" gives HMyHeading. Any other character is replaced by its hexadecimal Unicode code point, so "Café" gives HCafE9, which is easy to get wrong. To be sure of an id, display the page, look at its HTML source, and read the id attribute of the heading:

<h2 id="HMyHeading" class="wikigeneratedid"><span>My Heading</span></h2>
{{display reference="Sales.Reports.WebHome" section="HMyHeading"/}}

Display a Section Without Repeating Its Title

When the page already carries a heading of its own above the macro, excludeFirstHeading drops the displayed section's heading so the title is not read twice:

{{display reference="Sales.Reports.WebHome" section="HMyHeading" excludeFirstHeading="true"/}}

Related

Get Connected