How to create a template that links from one MediaWiki to another

mediawiki

I am trying to create a linkage between two media wiki. Specifically, a template that links to an specific article on the other wiki.

I would like to write

See {{otherwiki|Some thing}}

The template otherwiki should convert the above to

[http://linkto.other.wik/Some_thing Some thing]

The template I wrote works pretty well for single-word terms, and it works if I write Some_thing, but I can't get it to work for phrases that contain whitespace.

[https://en.bitcoin.it/wiki/{{{1}}} {{{1}}}]

How do I fix the above template to make it support whitespace?

Best Answer

One option would be to set up interwiki links to the target wiki. With that, you can either write your links directly as e.g. [[otherwiki:Some thing|]], or you can encapsulate that into a template ([[otherwiki:{{{1}}}|]]), so the syntax would be exactly as you wanted.

Another option is to use the magic word {{urlencode}}:

[https://en.bitcoin.it/wiki/{{urlencode:{{{1}}}|WIKI}} {{{1}}}]