(:groupheader:)(:Summary:Multiple mechanisms for creating links:) (:Audience: authors (basic) :) A key feature of [[wiki(WikiWeb)]]-based systems is the ease of creating %newwin%[[Wikipedia:Hyperlink|hyper links]]%% (or short '''links''') in the text of a document. PmWiki provides multiple mechanisms for creating such links. <:vspace> !! [[#links]]Links to other pages in the wiki <:vspace> To create an internal link to another page, simply enclose the name of the page inside double square brackets, as in [@[[wiki sandbox]]@] or [@[[installation]]@]. This results in links to [[wiki sandbox]] and [[installation]], respectively. <:vspace> PmWiki creates a link by using the text inside the double brackets. It does this by removing spaces between the words, and automatically capitalizing the first letter of each word following spaces or other punctuation (like ~). Thus [@[[Wiki Sandbox]]@], [@[[wiki sandbox]]@], and [@[[WikiSandbox]]@] all display differently but create the same link to the page titled [@WikiSandbox@]. Or in other words, PmWiki will automatically create the "link path name" using the page name in ''CamelCase'', but the "link text" will display in the format you have entered it. <:vspace> Some PmWiki sites (default not) will recognize words written in CamelCase, called a [[WikiWord]], automatically as a link to a page of the same name. <:vspace> !!! [[#othertext]]Links with different link text <:vspace> There are three ways to get a different link text: <:vspace> #'''Hide link text'''. Link text within (parentheses) will not be not displayed, so that [@[[(wiki) sandbox]]@] links to ''[=WikiSandbox=]'' but displays as [[(wiki) sandbox]]. For addresses actually containing parentheses, use %28 and %29 [[http://www.example.com/linkwith%28parenthese%29]]. <:vspace> #'''Change link text'''. You can specify another link text after a vertical brace, as in [@[[WikiSandbox | a play area]]@], or you can use an arrow ([@->@]) to reverse the order of the link text and the target, as in [@[[a play area -> WikiSandbox]]@]. Both links displays as [[a play area -> WikiSandbox]]. <:vspace> #'''Show page title instead of page name'''. The use of special characters in the page name is not a problem for PmWiki, but on some servers it may be better to use only plain A-Z letters for the page "name" (which is also a filename), and set the page "title" to the extended or international characters with the [=(:title PageTitle:)=] directive within the page. The page title can be shown instead of the page name with the [@[[PageName|+]]@] link markup, e.g. page [@BasicEditing@] contains the directive [=(:title=] {BasicEditing$Title}:) with the result that a link written as [@[[BasicEditing|+]]@] will display as [[BasicEditing|+]].\\ Since PmWiki version 2.2.14 this works also for those technical pages that have an entry in the XLPage, without the need to add the [=(:title PageTitleName:)=] directive within that page (for more details see [[(http://www.pmwiki.org/wiki/)Localization.Localization]]). <:vspace> On top of above ways, a suffix can be added to the end of a link, which becomes part of the link text but not of the target page name.\\ '''Note:''' This feature does currently not work with the [@[[PageName|+]]@] markup. <:vspace> [[#markupheaders]] (:table class='markup horiz' align='center':) (:cellnr class='markup1':) [-'''What to type'''-] (:cell class='markup2':) [-'''What it looks like'''-] (:tableend:) [[#markupheadersend]] <:vspace> (:markup class=horiz:) [[(wiki) sandbox]] [[(wiki) sandbox]]es [[WikiSandbox | wiki sandbox]], [[WikiSandbox | wiki sandbox]]es [[BasicEditing | +]] (:markupend:) <:vspace> !!! [[#tooltiptitle]] Links with tool tip From version 2.2.14 PmWiki can show tooltip titles with the following format: * External link: [@[[http://pmwiki.org"external tool tip title" | external link ]]@] eg [[http://pmwiki.org"external tool tip title" | external link ]] * internal link: [@[[Links"internal tool tip title" | internal link ]]@] eg [[Links"internal tool tip title" | internal link ]] * [[#anchors|Anchor links]]: [@[[#name"anchor tool tip title"|anchor link text]]@] (since Version 2.2.48) * [[InterMap]] link: [@[[Wikipedia:Wiki"tool tip title"| InterMap link ]]@] eg [[Wikipedia:Wiki"tool tip title"| InterMap link ]] * Linked [[Images|image]]: [@[[Attach:000962.png"tool tip title" | Attach: link]]@] * Inline [[Images|image]]: [@Attach:000962.png"tool tip title"@] <:vspace> !!! [[#nonexistent]]Links to nonexistent pages <:vspace> Links to [[nonexistent pages]] are displayed specially, to invite others to create the page. See [[Creating new pages]] to learn more. <:vspace> !!! [[#othergroup]]Links to pages in other wiki groups <:vspace> Links as written above are links between pages of the same group. To create a link to a page in another group, add the name of that other group together with a dot or slash as prefix to the page name. For example, links to [@Main/WikiSandbox@] could be written as: <:vspace> (:include {$FullName}#markupheaders#markupheadersend:) <:vspace> (:markup class=horiz:) * [[Main.WikiSandbox]] * [[Main/WikiSandbox]] * [[(Main.Wiki)Sandbox]] * [[Main.WikiSandbox | link text]] * [[Main.WikiSandbox | +]] (:markupend:) <:vspace> To link to the "default home page" of a group, the name of the page can be omitted: <:vspace> (:markup class=horiz:) * [[Main.]] * [[Main/]] (:markupend:) <:vspace> See [[Wiki Group]] to learn more about PmWiki groups. <:vspace> !!! [[#categories]]Category links <:vspace> Categories are a way to organize and find related pages. The idea is that every page that falls into a particular subject area should have a link to a shared page containing links to other pages on that subject. These ''shared pages'' are created in the special group [@Category@], and thus these subject areas are called "categories". <:vspace> Adding a page to the category [@Subject@] is simple by adding the [@[[!Subject]]@] markup somewhere on that page. This will create a link to the page [@Category.Subject@]. So [@[[!Subject]]@] is a kind of link shortcut to the page [@Category.Subject@]. See [[Categories]] to learn more. <:vspace> !!! [[#profiles]]User page links <:vspace> Similar is [@[[~Author]]@] a link shortcut to the page [@Author@] in the special group [@Profiles@]. PmWiki automatically creates this type of link for the ''current author'', when it encounters three tilde characters ([@~@]) in a row ([@~@][@~@][@~@]) in the page text. The current author is the name found in the "Author" field, when you create or modify a page. The current date and time is appended when four tilde characters in a row are encountered ([@~@][@~@][@~@][@~@]). <:vspace> So, when the Author field contains "Author":\\ [@~@][@~@][@~@] markup will be replaced by: [[~Author]]\\ [@~@][@~@][@~@][@~@] markup will be replaced by: [[~Author]] October 10, 2010, at 04:50 PM <:vspace> !!! [[#linkshortcuts]]Link shortcuts <:vspace> '''[@[[PageName|#]]@]''' creates a [[#reference|reference]] link as shown below'^[[#reference|#]]^'. <:vspace> !!! [[#anchors]]Links to specific locations within a page -- "anchors" <:vspace> To define a location, or bookmark, within a page to which you may jump directly, use the markup [@[[#name]]@]. This creates an "[[http://www.w3.org/TR/html4/struct/links.html#h-12.2.1|anchor]]" that uniquely identifies that location in the page. Then to have a link jump directly to that anchor, use one of <:vspace> * [@[[#name|link text]]@] within the same page, or * [@[[PageName#name]]@] or [@[[PageName#name|link text]]@] for a location on another page * The form [@[[PageName(#name)]]@] may be useful for hiding the anchor text in a link. <:vspace> For example, here's a link to the [[#intermaps | Intermaps]] section, below. <:vspace> Notes: * %red%The anchor itself [[http://www.w3.org/TR/html4/types.html#type-name|must]] begin with a letter%%, '''not a number'''. * A link to an anchor must have the '''same capitalization as the anchor''' itself. * Spaces are not allowed in an anchor: "[@[[#my anchor]]@]" won't work, "[@[[#myanchor]]@]" will. * All anchor names in a page should be unique. <:vspace> !!! [[#actions]]Links to actions <:vspace> To link to a specific action for the current page use [@[[{$FullName}?action=actionname|linkname]]@]. <:vspace> Examples: * [@[[{$FullName}?action=edit|Edit]]@] for editing * [@[[{$FullName}?action=diff|differences]]@] for differences. <:vspace> !! Links outside the wiki [[#externallinks]] !!! Links to external sites ([=URLs=]) <:vspace> Links to external sites simply begin with a prefix such as 'http:', 'ftp:', etc. Thus [@http://google.com/@] and [@[[http://google.com/]]@] both link to Google. As with the above, an author can specify the link text by using the vertical brace or arrow syntax, as in [@[[http://google.com/ | Google]]@] and [@[[Google -> http://google.com]]@]. <:vspace> It is possible to set a "tooltip title" of the external link by adding it in quotes after the address: (:markup caption='The tooltip title of the link is "Home of PmWiki"' class=horiz:)[@ [[http://www.pmwiki.org/"Home of PmWiki"|link]] @] <:vspace> If the external link includes (parentheses), escape these using [=%28=] for "(" and [=%29=] for ")" : (:markup:)[=[[http://en.wikipedia.org/wiki/Wiki_%28disambiguation%29 | link to "Wiki (disambiguation)" ]]=] <:vspace> The recipe Cookbook:FixURL makes it easy to encode parentheses and other special characters in link addresses. <:vspace> !!! Links to intranet (local) files <:vspace> '''Not all browsers will follow such links''' (some Internet Explorer versions reportedly follow them). You can link to a file system by including the prefix [@'file:///'@]. So [@file:///S:\ProjPlan.mpp@] and [@[[Shared S drive->file:///S:\]]@] are both valid links. On a Windows file system you may want to use network locations (eg \\server1\rootdirectory\subdirectory) rather than drive letters which may not be consistent across all users. Not all browsers will follow such links. <:vspace> See also Cookbook:DirList. <:vspace> !! Link characteristics !!! [[#reference]]Links as References <:vspace> Links may also be specified as '''References''', so the target appears as an anonymous ''numeric'' reference rather than a ''textual'' reference. The following markup is provided to produce sequential reference numbering within a PmWiki page: <:vspace> Formatting the link as: [@[[http://google.com |#]]@] produces: [[http://google.com |#]] as the link. <:vspace> Subsequent occurrence of the reference link format on the same page will be incremented automatically as per the following example: Entering [@[[http://pmwiki.com |#]]@] produces [[http://pmwiki.com |#]], [@[[#intermaps |#]]@] produces [[#intermaps |#]], and so on for further reference links. <:vspace> !!! [[#intermaps]]Intermaps <:vspace> [[Inter Map]] links are also supported (see [[Inter Map]]). In particular, the [@Path:@] InterMap entry can be used to create links using relative or absolute paths on the current site (e.g., [@Path:../../somedir/foo.html@] or [@Path:/dir/something.gif@]). <:vspace> !!! Links that open a new browser window <:vspace> To have a link open in another window, use [@%newwin%...%%@]: <:vspace> * [@%newwin% http://pmichaud.com %%@] produces %newwin% http://pmichaud.com %% * [@%newwin% [[http://google.com/ | Google]] %%@] produces %newwin% [[http://google.com/ | Google]]%% * [@%newwin% [[Main.WikiSandbox]] %%@] produces %newwin% [[Main.WikiSandbox]]%% <:vspace> You can also specify that links should open in a new window via the @@[=%target=_blank%...%%=]@@ attribute: <:vspace> (:markup class=horiz:) The following link %target=_blank% http://pmichaud.com %% will open in a new window. (:markupend:) <:vspace> !!! [[#robots]]Links that are not followed by [[(PmWiki:)robots]] <:vspace> Prefix a link with [=%rel=nofollow%=] to advise %newwin rel=nofollow%[[http://robotstxt.org/|robots]] and [[http://validator.w3.org/checklink|link checkers]]%% not to follow it. <:vspace> <:vspace> !! Links and CSS Classes <:vspace> PmWiki automatically gives classes to several types of links. Among other things, this enables you to format each type differently. <:vspace> Note: This may be an incomplete list. :.selflink:A link to the current page. Useful in sidebars to show "you are here". :.wikilink:A link to another page within the wiki. :.urllink:A link to a page outside the wiki. <:vspace> !! Notes <:vspace> '''Note:''' The default behavior of "+" above can be overridden to display the spaced title, rather than simply the title by adding the following to config.php: ->[@ ## [[target |+]] title links Markup('[[|+', '<[[|', "/(?>\\[\\[([^|\\]]+))\\|\\s*\\+\\s*]]/e", "Keep(MakeLink(\$pagename, PSS('$1'), PageVar(MakePageName(\$pagename,PSS('$1')), '\$Titlespaced') ),'L')"); @] <:vspace> <:vspace> >>faq<< [[#faq]] <:vspace> Q: How do I create a link that will open as a new window? <:vspace> A: Use the [@%newwin%@] wikistyle, as in: (:markup class=horiz:) [=%newwin% http://example.com/ %%=] <:vspace> Q: How do I create a link that will open a new window, and configure that new window? <:vspace> A: This requires javascript. See [[Cookbook:PopupWindow]]. <:vspace> Q: How do I place a mailing address in a page? <:vspace> A: Use the [@mailto:@] markup, as in one of the following: <:vspace> (:markup class="horiz":) * mailto:myaddress@example.com * [[mailto:myaddress@example.com]] * [[mailto:myaddress@example.com | email me]] * [[mailto:myaddress@example.com?subject=Some subject | email me]] (:markupend:) The markup @@[=[[mailto:me@example.=]com?%red%cc=%%someoneelse@example.com%red%&bcc=%%else@example.com%red%&subject=%%Pre-set Subject%red%&body=%%Pre-set body | display text]] =]@@ lets you specify more parameters like the message body and more recipients (may not work in all browsers and e-mail clients). <:vspace> See also [[Cookbook:DeObMail]] for information on protecting email addresses from spammers. <:vspace> Q: How can I enable links to other protocols, such as nntp:, ssh:, xmpp:, etc? <:vspace> A: See [[Cookbook:Add Url schemes]] {Cookbook.AddUrlSchemes$:Summary} <:vspace> Q: How do I make a WikiWord link to an external page instead of a WikiPage? <:vspace> A: Use link markup. There are two formats: <:vspace> ->[@[[http://example.com/ | WikiWord]] [[WikiWord -> http://example.com/]]@] <:vspace> Q: How do I find all of the pages that link to another page (i.e., backlinks)? <:vspace> A: In the wiki search form, use @@link=Group.Page@@ to find all pages linking to Group.Page. <:vspace> A: Use the [@link=@] option of the [[[@(:pagelist:)@] directive -> PmWiki/PageLists#pagelistlink]], as in <:vspace> ->[@(:pagelist link=SomePage list=all:) -- show all links to SomePage (:pagelist link={$FullName} list=all:) -- show all links to the current page@] <:vspace> <:vspace> Q: What link schemes does PmWiki support? A: See [[PmWiki:Link schemes]] {PmWiki.LinkSchemes$:Summary} <:vspace> Q: How do I open external links in a new window or mark them with an icon? A: See [[Cookbook:External links]] {Cookbook.ExternalLinks$:Summary} <:vspace> Q: How can I use an image as a link? A: Use [=[[Page| Attach:image.jpg ]] or [[ http://site | http://site/image.jpg ]]=] See [[PmWiki/Images#links]] <:vspace> Q: Why my browser does not follow local file:// links? A: For security reasons, most browsers will only enable file:// links if the page containing the link is itself on the local drive. In other words, most browsers do not allow links to file:// from pages that were fetched using http:// such as in a PmWiki site. See also Cookbook:DirList for a workaround.(:groupfooter:) <:block>