Link Reference in the Wiki

From RCGRS MRT Wiki
Revision as of 10:36, 26 January 2024 by DErik (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

One of the confusing things about creating links to pages is that the syntax of the link reference is dependent on the "domain" of the page, which may be this instance of MediaWiki, or some other instance like Wikipedia, or MediaWiki itself (which really is its own instance of the MediaWiki application). In some instances, the full URL is needed, in others, the substitution of "mediawikiwiki:" for "https://MediaWiki.org/" works, and others do not require either the full URL or the substitution.
This article is being developed by Don Erikstrup (DErik (talk) 18:20, 2 May 2023 (PDT))


For example: the "Special" page that lists all the pages in this instance of MediaWiki (i.e., the RCGRS.com version) has the full URL of

https://www.rcgrs.com/mrtwiki/index.php?title=Special:AllPageshttps://www.rcgrs.com/mrtwiki/index.php?title=Special:AllPages

and it can be included in any page just that way. It can also be referenced with single brackets around it like so:

[https://www.rcgrs.com/mrtwiki/index.php?title=Special:AllPages][1]

Note that the last example just provides the reference link as a number. Not very useful or informative as to what is being referenced. To fix that, it could include text that provides some sensible indication as to what the reference links to. (This is called "link text" in some of the help files.) Here are examples with "link text":

[https://www.rcgrs.com/mrtwiki/index.php?title=Special:AllPages List all pages]List all pages

Now, because these are full URLs (they include the communications protocol specification of https://) they are treated as external links, and that is why the syntax above is just one set of square brackets or none at all, and why the "link text" is delimited from the "reference text" by a space character. But the "Special" pages are typically internal pages. That is, they are specific to this instance of the MediaWiki installation. Note that the URL has www.rcgrs.com/mrtwiki/index.php?title= as part of it. This is the "domain" of the page, followed by any directories the reference resides within, and optional arguments that tell the HTML processor more about what should be included in the displayed reference. (Don't worry if you don't understand that part. Just think of it as the "reference text" as a whole.) The part that specifies the domain, rcgrs.com, is how we know it is really specific to this MediaWiki installation instance; other instances have different domains. So, since it is internal, it can be referenced with just the page title, with or without additional text, wrapped in double square brackets, and delimiting the "link text" with a pipe ("|") character, like so:

[[Special:AllPages]]Special:AllPages
[[Special:AllPages|List all pages]]List all pages

The reason there are differences in the syntax between internal and external links is beyond the scope of this article. Just accept it. When trying to reference an internal page with just one set of square brackets, and changing the "link text" syntax, this happens:

[Special:AllPages] ⟹ [Special:AllPages]
[Special:AllPages List all pages] ⟹ [Special:AllPages List all pages]

Well that just doesn't work at all. It doesn't even recognize it as a link. Let's try doing the last form to access an external page, like the MediaWiki main help file:

[Help:Contents Attempt to display MediaWiki help] ⟹ [Help:Contents Attempt to display MediaWiki help]

It again doesn't even recognize it as a link. The problem here is that the single brackets indicate to the MediaWiki application that the reference should be to an external page, and an external page requires the communications protocol (at least a double slash ("//"), I think MediaWiki assumes the "http:" or "https:" if just the "//" is present - I recall reading that somewhere) and domain to be included. So wrap it in another set of square brackets (and change "link text" delimiter), to make it think it is an internal page:

[[Help:Contents|Attempt to display MediaWiki help]]Attempt to display MediaWiki help

At least it is recognized as a link, but note that the reference is in red letters. This indicates the page could not be found by MediaWiki. Why? Because it really isn't an internal page. So let's try it again with protocol and domain added:

[//www.MediaWiki.org/Help:Contents|Attempt to display MediaWiki help]Attempt to display MediaWiki help

Well, that recognized it as a link reference, but the link doesn't work (not found error). Why? Because MediaWiki actually puts this stuff in a directory called wiki. So we need to include that in the reference text:

[https://www.MediaWiki.org/wiki/Help:Contents|Attempt to display MediaWiki help]Attempt to display MediaWiki help

OK, that works. How did I know it was in that wiki directory? Well, I had looked up help via some other link and took note of the actual URL. Also, when I got the "404 Not found" error, the page asked if I really meant wiki/Help:Contents. That was nice of them.


Now recall my mention of "mediawikiwiki:"? Let's try substituting that for the protocol and MediaWiki domain specification in a reference to their help file.
First the full reference as it would normally be done:

[http://www.MediaWiki.org/wiki/Help:Contents Attempt to display MediaWiki help]Attempt to display MediaWiki help

Now the revised reference:

[[MediaWikiwiki:Help:Contents|Attempt to display MediaWiki help]]Attempt to display MediaWiki help

Note that I have now wrapped the reference in double square brackets and delimited the "link text" with a pipe ("|") rather than a space. This is because it is now considered an internal reference, and must therefore follow that syntax.


I hope that helps you when you are trying to figure out why your links aren't working. For more details on links in the wiki, see https://www.mediawiki.org/wiki/Help:Links. If you have any comments or questions regarding this, just click on the this: "discussion", or on the "discussion" tab at the top of this article. You can also "talk" to me about anything by clicking the link behind my name below and put your comments and questions in there. I'll get notified and answer as soon and as best as I can.
Have fun.

--DErik (talk) 23:47, 2 May 2023 (PDT)