Include Macro

Version 748.1 by Admin on 2022/07/23 06:48

cogInclude an entity (document, property, etc.)
Developed by

XWiki Development Team

0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Installable with the Extension Manager


Include other pages into the current page. By default this macro acts as if the included content was copied in the including page (e.g. if you include a page with relative links to images, they won't be found since they won't exist in the including page). If, instead you wish to include the result of what you get when you view the included page, use the display macro instead.


From WYSIWYG Editor


From Wiki Syntax

{{include page="page1/page2"/}}

Parameters definition

NameOptionalAllowed valuesDefault valueDescription
pageno or referenceA page reference Since 10.6The reference of the page to include. You should use this parameter rather than the reference one which is more complex to use.
referenceno or pagean entity reference The reference of the entity to include. See the Model module to understand the concept of references.
typeyesdocumentdocumentThe type of the entity. This parameter is also only useful when used with the reference parameter. It's not needed when using the page parameter.
sectionyesstringThe id to the Heading section to include in the target document. To do that you'll need to find out the id that is automatically generated by XWiki. To find it you have 2 solutions:
  • Compute it yourself by following this algorithm: "H" + heading title stripped of all non alpha characters. For example if your heading title is My Heading, the id will be HMyHeading.
  • View the HTML source of the page in your browser and find the id that was generated. For example, for a level 2 heading title of My Heading, the HTML will be <h2 id="HMyHeading" class="wikigeneratedid"><span>My Heading</span></h2>, and thus the id to use is the one from the id attribute, i.e. HMyHeading.

Note that in the future we plan to improve it.

documentnoa wiki document The name of the document to include. Deprecated since 3.4M1. Use page (or reference) instead.
contextyesnew/currentcurrentDefines whether the included page is executed in its separated execution context or whether it's executed in the context of the current page. Deprecated since 3.4M1. Use display macro for context=new.
excludeFirstHeadingyestrue or falsefalseSince 12.4RC1If true, exclude the heading from the included page if the first element of that page is a heading.


Example 1:

{{include page="Page1/Page2"/}}

Example 2 (if you want to include a page from another wiki):

{{include page="somewiki:Page1/Page2"/}}

Example 3:

{{include page="Page1/Page2" section="HMySection"/}}

Example 4 (using the reference parameter):

{{include reference="Page1.Page2.WebHome" /}}

NOTE: Be sure to include the / within the "/}} at the end, otherwise any content that comes after the included section on this page will fail to appear.

Including velocity macros

To include the macros of another page for use in this page use something as follows:

{{include reference="Macros" /}}

The #macros() and $variables of the Macros page are now visible.

NOTE: The include macro must be outside the velocity macro and before it as a page with some velocity is always first parsed for its external wiki syntax; meeting a velocity block then produces the wiki syntax which is parsed afterwards. This would mean that using the include macro inside velocity would trigger the inclusion only after the velocity code is finished.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.


Dependencies for this extension (org.xwiki.platform:xwiki-platform-rendering-macro-include 14.5):

Tags: include

Get Connected