Implict MediaWiki/Gollum-style [[page links]]

As an extension, it would be useful to be able to type link text in double square brackets and have a relative URL be generated automatically. Variations of the double square bracket syntax can be found on MediaWiki and Gollum wikis.

Gollum page links look like this:

[[Frodo Baggins]]

Producing:

<a href="/frodo-baggins">Frodo Baggins</a>

MediaWiki accepts the following syntax:

[[Frodo Baggins]]

Which produces:

<a href="/wiki/Frodo_Baggins">Frodo Baggins</a>

I prefer hyphens to underscores, and my understanding is that search engines do as well. My suggestion is to go with the Gollum syntax.

It might also be worth removing the forward slash at the beginning of the href output. For example:

[[Frodo Baggins]]

would instead produce:

<a href="frodo-baggins">Frodo Baggins</a>

This means that if the Frodo Baggins article was nested under /wiki, you could get to it from another article also nested under /wiki without needing to type [Frodo Baggins](/wiki/frodo-baggins) using the regular Markdown link syntax.

As further polish, URLs could be generated cleanly, replacing special characters with words. The Stringex library for Ruby does this particularly well. Here are the examples from the Stringex readme, but using the proposed page link syntax:

[[simple English]]

<a href="simple-english">simple English</a>

[[it's nothing at all]]

<a href="its-nothing-at-all">it's nothing at all</a>

[[rock & roll]]

<a href="rock-and-roll">rock & roll</a>

[[$12 worth of Ruby power]]

<a href="12-dollars-worth-of-ruby-power">$12 worth of Ruby power</a>

[[10% off if you act now]]

<a href="10-percent-off-if-you-act-now">10% off if you act now</a>

[[kick it en Français]]

<a href="kick-it-en-francais">kick it en Français</a>

[[rock it Español style]]

<a href="rock-it-espanol-style">rock it Español style</a>

[[tell your readers 你好]]

<a href="tell-your-readers-ni-hao">tell your readers 你好</a>

2 Likes

Is there any relation to:?

http://talk.commonmark.org/t/compact-uris-curies/553

Basically, you “declare root url” on top of page, and then use CURIEs to append the root url to your url. If you could combine CURIEs with your proposal, then that might be useful. Perhaps the root url can be declared via document metadata or sitewide options.

I haven’t looked into that topic yet, but in this case the wiki style links are just a shorthand for writing normal Markdown links.

[[Frodo Baggins]]

is shorthand for:

[Frodo Baggins](frodo-baggins)

Whatever extensions apply to the latter would apply to the former too.

2 Likes

Okay. Hmmm… well my next concern will be. If we have relative links in a document. What would happen if we relocate the document to a different website or location. Do you have a way to declare in perhaps the document declaration metadata on what is the original root url for the relative urls. e.g.

% relativeURL(INPUT) = http://en.wikipedia.org/wiki/INPUT

[[Analytical_Review]] 
   Links to --> http://en.wikipedia.org/wiki/Analytical_Review  

Also can you declare more than one kind of root url… e.g.

[[google:cat]] 
   Links to --> https://www.google.com/?q=cat#q=cat
[[wikipedia:Analytical_Review]] 
   Links to --> http://en.wikipedia.org/wiki/Analytical_Review

edit: Okay, I moved the concept over to CURI

IMO, it’s a feature that the URLs are relative. If Wikipedia changed their domain, or another site forks the project (which actually happened with Citizendium), the URLs will continue to work.

There might be some cases where you would want to explicitly declare a root URL, but let’s discuss that in the Compact URLs topic since that is a different feature from what I am proposing here.

1 Like

Implicit wiki links are also used in Taiga Markdown:

https://taiga.io/support/taiga-markdown-syntax/#taiga-wiki-links

Been using https://obsidian.md often these days and it is essentially an integrated wiki which uses [[page link]] for quick links between pages.

It looks like some Jekyll static websites also use wiki links like here, but is mostly via plugins like what is talked in this discussion Introducing -- jekyll-wikilinks! - Share - Jekyll Talk .

Not sure if common enough for the next commonmark standard, but should at least be noted.

1 Like