XWikiSyntaxLinks

Last modified by Simon Urli on 2022/10/27

Editing

FeatureXWiki Syntax 1.0Result
Link to a page in the current Space[WebHome]Web Home
Link with a label[label>WebHome]label
Link with XWiki Syntax in the label<a href="$xwiki.getURL("WebHome")"><strong>bold label</strong></a>bold label
Link to a page with the space specified[Main.WebHome]Web Home
Link to a subwiki[subwiki:Main.WebHome]Web Home
Link that opens in a new window[label>WebHome>_blank]label
Link to a URL directly in the textThis is a URL: https://xwiki.orgThis is a URL: https://xwiki.org
Link to a URL[https://xwiki.org]https://xwiki.org
Link to a URL with a label[XWiki>https://xwiki.org]XWiki
Link to an email address[[email protected]>mailto:[email protected]][email protected]
Image Link<a href="$xwiki.getURL("Space1.Page1")">{image:img.png|document=Space2.Page2}</a>img.png
Image Link with image parameters<a href="$xwiki.getURL("Space1.Page1")">{image:img.png|document=Space2.Page2|width=26|height=26}</a>img.png
Link to an attachment on the current page

See Attach Macro for details
{attach:text|file=img.png}

text
Link to an attachment in a different page

See Attach Macro for details
{attach:text|document=Space.Page|file=img.png}

text
Link to an Anchor in a page[label>Space.Page#anchor]label
Link to a Heading in a page
[label>Space.Page#HMyheading]
label

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".

$subHeading XWiki Syntax 1.0 Link Specification $subHeading

Part in ( ) is required, parts in [ ] are optional and one of the two chars in { } needs to be added if optional parts are being used.

The full format of a link is [label {> or |}] (resource) [@interWikiAlias] [{> or |} target]

  • label: An optional string which will be displayed to the user as the link name when rendered. Example: My Page
  • resource: The full link reference using the following syntax: (reference) [?queryString] [#anchor]
    • reference: The link reference. This can be either
      • A URI in the form protocol:path (examples: http://xwiki.org, mailto:[email protected]), or
      • A wiki page reference in the form [[wikiName:] spaceNameList.] (pageName). Examples: WebHome, Main.WebHome, mywiki:Main.WebHome
        • wikiName: An optional string containing the name of a wiki. The link will point to a page inside that wiki. 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: WebHome
    • queryString: An optional query string for specifying parameters that will be used in the rendered URL. Example: 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: HTableOfContents
  • interWikiAlias: An optional Inter Wiki alias as defined in the InterWiki Map (see the Admin Guide). This is only valid for wiki page names. Example: wikipedia
  • target: An optional string corresponding to the Hhttps://TML target attribute for a HTML A link element. This element is used when rendering the link. It defaults to opening the link in the current window. Examples: _self, _blank
FeatureXWiki Syntax 2.0Result
Link to a page in the current Space[[WebHome]]XWiki
Link with a label

[[label>>WebHome]]
XWiki Syntax is supported inside link labels.

label
Link with XWiki Syntax in the label[[**bold label**>>WebHome]]bold label
Link to a page with the space specified[[Main.WebHome]]Main
Link to a subwiki[[subwiki:Main.WebHome]]Main
Link that opens in a new window[[label>>WebHome||target="_blank"]]label
Link to a URL directly in the textThis is a URL: https://xwiki.orgThis is a URL: https://xwiki.org
Link to a URL[[https://xwiki.org]]https://xwiki.org
Link to a URL with a label[[XWiki>>https://xwiki.org]]XWiki
Link to an email address[[[email protected]>>mailto:[email protected]]][email protected]
Image Link[[image:[email protected]>>Space1.Page1]]img.png
Image Link with image parameters[[[[image:[email protected]||width="26" height="26"]]>>Space1.Page1]]img.png
Link to an attachment on the current page[[text>>attach:img.png]]text
Link to an attachment in a different page[[text>>attach:[email protected]]]text
Link to an Anchor in a page[[label>>Space.Page#anchor]]label
Link to a Heading in a page[[label>>Space.Page#HMyheading]]label
Link to an Anchor in the current page[[label>>#anchor]]label

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".

$subHeading XWiki Syntax 2.0 Link Specification $subHeading

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

The full format of a link is [label>>] (resource) [@interWikiAlias] [||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: The full link reference using the following syntax: (reference) [?queryString] [#anchor]
    • reference: The link reference in one of the following forms:
      • URL: Any URL in the form of protocol://path. Examples: http://xwiki.org, https://svn.xwiki.org/
      • Wiki page reference in the form [[wikiName:] spaceNameList.] (pageName). Examples: WebHome, Main.WebHome, mywiki:Main.WebHome
        • wikiName: An optional string containing the name of a wiki. The link will point to a page inside that wiki. 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: WebHome
      • Attachment reference in the form attach: [wikiPageName@] (attachmentName). Examples: attach:img.png, attach:mywiki:[email protected]
        • attach: A required string identifying the resource as attachment.
        • wikiPageName: An optional string referencing the page that holds the attachment, see "Wiki page" above.
        • attachmentName: Name of the attachment as it is stored in the wiki.
      • Email address in the form mailto: (emailAddress) (#anchor is not valid). Example: mailto:[email protected]
        • mailto: A required string identifying the resource as email.
        • emailAddress: Targeted email address. Example: "[email protected]"
    • queryString: An optional query string for specifying parameters that will be used in the rendered URL. Example: 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 and images. Example: HTableOfContents
  • interWikiAlias: An optional Inter Wiki alias as defined in the InterWiki Map (see the Admin Guide). This is only valid for wiki page names. Example: wikipedia
  • parameters: An optional list of parameters passed to the link. Example: target="_blank" (open in new window)
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]]

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:[email protected]>>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: https://xwiki.orgThis is a URL: https://xwiki.org
Explicit link to a URL[[https://xwiki.org]]https://xwiki.org
Explicit link to a URL with a label[[XWiki>>https://xwiki.org]]XWiki
Link to an email address[[[email protected]>>mailto:[email protected]]][email protected]
Link to an attachment on the current page[[attach:img.png]]img.png
Link to an attachment in a different page[[attach:[email protected]]]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"]]

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

$subHeading XWiki Syntax 2.1 Link Specification $subHeading

Legend: The parts in () are 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.
      • protocol://path: The URL itself
    • Wiki page: A reference in the form page:[(wikiName):](pageNameList). Examples: page:Page, page:myxwiki:Page, page:ParentPage.ChildPage.SubChildPage, page:../SiblingPage, page:./ChildPage
      • page: A required string identifying the resource as an XWiki page. The same reference can be used for either a terminal or non-terminal page, if both exist it will lead to the non-terminal page.
      • wikiName: An optional string containing the name of a wiki. The link will point to a page inside that  wiki. If no wiki is specified, the current wiki is used. Example: mywiki
      • pageNameList: A required list of slash-separated wiki Pages names pointing to the final linked wiki Page syntax. It's also possible to use . and .. to indicate current or parent page/wiki. Examples: Main, A/B, A/B/C, ../Sibling, ./Child
    • Wiki document: A reference in the form [doc:][[(wikiName):](spaceNameList).](documentName). Examples: doc:Welcome, doc:Main.Welcome, doc:mywiki:Main.Welcome, Welcome
      • doc: An optional 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 wiki. The link will point to a page inside that 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
      • documentName: A required string containing the name of the linked wiki page. Example: Welcome
    • Wiki space: A 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 wiki. The link will point to a page inside that 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: A 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: A reference in the form attach:{{{(wikiName):}(spaceNameList).}(pageName)@}(imageName)
      • attach: A required string identifying the reference as an XWiki Document attachment.
      • wikiName: An optional string containing the name of a wiki. The image reference will point to an image attached to a page inside that 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: An optional string containing the name of the wiki page to which the referenced image is attached. Example: Welcome
      • attachmentName: Name of the attachment as it is stored in the wiki. Example: photo.png
    • Page Attachment: A reference in the form pageAttach:{{{(wikiName):}(pageNameList)/}(imageName)
      • pageAttach: An required string identifying the reference as an XWiki Page attachment.
      • wikiName: An optional string containing the name of a wiki. The image reference will point to an image attached to a page inside that wiki. If no wiki is specified, the current wiki is used. Example: mywiki.
      • pageNameList: An optional dot-separated list of wiki page names. If no page is specified the current page is used. Examples: Main, A/B, A/B/C
      • attachmentName: Name of the attachment as it is stored in the wiki. Example: photo.png
    • Email address: A reference in the form mailto:(emailAddress) (#anchor is not valid). Example: mailto:[email protected]
      • mailto: A required string identifying the resource as email.
      • emailAddress: Targeted email address. Example: [email protected]
    • Relative path: A 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): A 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  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 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 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: 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: 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 and images. 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"
Tags:
   

Get Connected