I want to create an infobox template using Fandom's Wikitext that has data which links to Wikipedia. So, if someone uses the template like:
{{Person Infobox
| city=Los Angeles
}}
it would be display in the infobox as:
City: Los Angeles
I tried:
<infobox>
<data source="city">
<label>City</label>
<format>[https://en.wikipedia.org/wiki/{{{city}}} {{{city}}}]</format>
</data>
</infobox>
but the link breaks if the data has spaces.
How do I replace the spaces in {{{city}}}
with %20
or is it impossible?
Fandom help forum is probably a better place for this type of questions, but there are two ways to do that:
urlencode
[https://en.wikipedia.org/wiki/{{urlencode:{{{city}}}|PATH}} {{{city}}}]
See https://www.mediawiki.org/wiki/Help:Magic_words
Interwiki link
In this method you use double brackets and a pipe like in internal links:
[[wikipedia:{{{city}}}|{{{city}}}]]