XWiki Syntax Guide

Last modified by Thomas Mortagne on 2016/12/26 12:13

FeatureXWiki Syntax 2.1Result
Absolute link to page PageB located in PageA[[PageA.PageB]]PageB
Relative link to page PageA from the current page[[PageA]] or [[.PageA]]PageA
Relative link to page PageB in PageA from the current page[[.PageA.PageB]]PageB
Link with a label
[[label>>PageA]]
IconInformation

XWiki Syntax is supported inside link labels.

label
Link with wiki syntax in the label[[**bold label**>>PageA]]bold label
Link on an image[[image:PageA@img.png>>PageA]]img.png
Absolute link to page PageB located in PageA in wiki WikiA[[WikiA:PageA.PageB]]PageB
Link that opens in a new window[[PageA||target="_blank"]]PageA
Implicit link to a URLThis is a URL: http://xwiki.orgThis is a URL: http://xwiki.org
Explicit link to a URL[[http://xwiki.org]]http://xwiki.org
Explicit link to a URL with a label[[XWiki>>http://xwiki.org]]XWiki
Link to an email address[[john@smith.net>>mailto:john@smith.net]]john@smith.net
Link to an attachment on the current page[[attach:img.png]]img.png
Link to an attachment in a different page[[attach:PageA.PageB@img.png]]img.png
Link to an Anchor in a page[[PageA.PageB||anchor="anchor"]]PageB
Link to a Heading in a page
[[PageA.PageB||anchor="HMyheading"]]
IconInformation

When you add a Heading, an anchor named "H" followed by the heading title with only alpha characters is created. For example, for a Heading named "My heading", the generated anchor will be "HMyheading".

PageB
Link to an anchor in the current page[[label>>||anchor="anchor"]]label
Link to a page with a query string[[PageA.PageB||queryString="param1=value1&param2=value2"]]PageB
Link to the current page with a query string[[label>>||queryString="param1=value1&param2=value2"]]label

XWiki Syntax 2.1 Link Specification

IconInformation

The part in ( ) is required, while the parts in [ ] are optional.

The full format of a link is [label>>] (resource) [||parameters]

  • label: An optional string which will be displayed to the user as the link name when rendered. The label may contain XWiki Syntax. If no label is specified a default label will be generated. The generation pattern can be changed, see the Admin Guide. Example: My Page
  • resource: A required string with the link reference in one of the following forms
    • URL: Any URL in the form of [url:] (protocol://path). Examples: http://xwiki.org, url:https://svn.xwiki.org/
      • url: An optional string identifying the resource as an URL.
    • Wiki page reference in the form (doc: ) [[wikiName:] spaceNameList.] (pageName). Examples: doc:Welcome, doc:Main.Welcome, doc:mywiki:Main.Welcome
      • doc: A required string identifying the resource as an XWiki terminal page. A non-terminal page can also be referenced this way, but it must append its .WebHome part (e.g. doc:Sandbox.WebHome).
      • wikiName: An optional string containing the name of a virtual wiki. The link will point to a page inside that virtual wiki. If no wiki is specified, the current wiki is used. Example: mywiki.
      • spaceNameList: An optional dot-separated list of wiki Space names. If no space is specified the current space is used. Examples: Main, A.B, A.B.C
      • pageName: A required string containing the name of the linked wiki page. Example: Welcome
    • Wiki space IconInformationSince 7.4.1 reference in the form (space: ) [wikiName:] (spaceNameList). Examples: space:Main, space:mywiki:Main, space:A.B.C
      • space: A required string identifying the resource as an XWiki non-terminal page (i.e. a space).
      • wikiName: An optional string containing the name of a virtual wiki. The link will point to a page inside that virtual wiki. If no wiki is specified, the current wiki is used. Example: mywiki
      • spaceNameList: A required list of dot-separated wiki Space names pointing to the final linked wiki Space (or non-terminal page). Examples: Main, A.B, A.B.C
    • InterWiki page reference in the form interwiki: (interWikiAlias: ) (pageName). Example: interwiki:wikipedia:XWiki
      • interwiki: A required string identifying the resource as an InterWiki link.
      • interWikiAlias: An optional Inter Wiki alias as defined in the InterWiki Map (see the Admin Guide). Example: wikipedia
      • pageName: A required string containing the name of the linked page. Example: XWiki
    • Attachment reference in the form attach: [wikiPageName@] (attachmentName). Examples: attach:img.png, attach:mywiki:Main.WebHome@img.png, attach:mywiki:Main@img.png
      • attach: A required string identifying the resource as attachment.
      • wikiPageName: An optional string referencing the (terminal or non-terminal) page that holds the attachment. This is resolved identically to "Untyped", below.
      • attachmentName: Name of the attachment as it is stored in the wiki. Example: photo.png
    • Email address in the form mailto: (emailAddress) (#anchor is not valid). Example: mailto:john@smith.com
      • mailto: A required string identifying the resource as email.
      • emailAddress: Targeted email address. Example: john@smith.com
    • Relative path reference on the server in the form path: (relPath). Example: path:$doc.getURL('reset') produces target address http://server.domain.com/xwiki/bin/reset/Space/Page where /xwiki/bin/reset/Space/Page is produced by $doc.getURL('reset').
      • path: A required string identifying the resource as a relative path.
      • relPath: A required string containing the relative path of the resource on the server that shall be linked.
    • UNC (Windows Explorer) reference in the form unc: (path). The link is rendered as a file:// link. Examples: unc:C:\Windows\, unc:\\myserver\path\img.png, unc:home/user/somefile
      • unc: A required string identifying the resource as a UNC (Windows Explorer) path.
      • path: A required string containing the local path of resource accessible by the user. Examples: C:\Windows\, \\myserver\path\img.png, home/user/somefile
    • Untyped: If none of the above mentioned resource types are specified (i.e. no type: resource prefix was specified in the link), then the link will be treated as a link to an XWiki terminal or non-terminal page using the following algorithm:
      • Terminal page in the current space, only if it exists. Example: [[A]] is resolved to the equivalent of [[doc:currentSpace.A]]
      • Non-terminal page IconInformationSince 7.4.1 in the current space. Example: [[A]] is resolved to the equivalent of [[space:currentSpace.A]], which is the equivalent of [[doc:currentSpace.A.WebHome]]
      • If the current page is non-terminal and the previous 2 checks above did not find an existing page, 2 additional checks are made:
        • Terminal page IconInformationSince 7.4.1 as sibling in the parent space, only if it exists. Example: The [[B]] link inside the non-terminal page A.C is resolved to the equivalent of [[doc:A.B]]
        • Non-terminal page IconInformationSince 7.4.1 as sibling in the parent space, regardless if it exists or not. Example: The [[B]] link inside the non-terminal page A.C is resolved to the equivalent of [[space:A.B]], which is the equivalent of [[doc:A.B.WebHome]]
      • Note1 - Absolute links: IconInformationSince 7.4.1 If the untyped link has 2 or more dot-separated components specified (i.e. that look like a space name and a page name), the above algorithm will resolve the page relative to the current wiki, and not the current space. Example: [[A.B]] can be resolved to either [[doc:currentWiki:A.B]] (if it exists) or to [[space:currentWiki:A.B]] (equivalent of [[doc:currentWiki:A.B.WebHome]]) and not to [[doc:currentWiki:currentSpace.A.B]] or [[doc:currentWiki:currentSpace.A.B.WebHome]].
      • Note2 - Special handling of .WebHome: IconInformationSince 7.4.1 If the untyped link ends in .WebHome, it will always be handled as a terminal page. Example: [[A.WebHome]] will always be resolved to the equivalent of [[doc:A.WebHome]] and not to [[doc:A.WebHome.WebHome]].
  • parameters: An optional list of space-separated parameters passed to the link. Example: queryString="mydata1=5&mydata2=Hello" anchor="HTableOfContents" target="_blank"
    • queryString: An optional query string for specifying parameters that will be appended to the link target address and used in the rendered URL. Example: url:http://domain.com/path||queryString="mydata1=5&mydata2=Hello" produces target address http://domain.com/path?mydata1=5&mydata2=Hello
    • anchor: An optional anchor name pointing to an anchor defined in the referenced link. Note that in XWiki anchors are automatically created for headings. Example: url:http://domain.com/path||anchor="HTableOfContents" produces target address http://domain.com/path#HTableOfContents
    • target: An optional parameter that allows to open link target in new window. Example: target="_blank"