This template uses Lua: |
This template takes a wiki URL and outputs the equivalent wikilink, with optional display text. It is useful for quickly creating properly formatted wikilinks to talk page sections or external wikis. It accepts URLs from most Wikimedia wikis. The template should usually be substituted, but will work with transclusion as well.
If given a partial URL (without the protocol and the host name) the template will remove any underlines and decode percent-encoded characters. If given a valid URL that is not recognised as a Wikimedia wiki, it will output the URL unlinked. See below for how to add new wikis.
The shortcut {{u2w}}
is available.
A similar URL-to-wikitext transformation can be done directly in the edit window using the User:Js/urldecoder user script.
{{subst:u2w|<!-- URL -->|<!-- display text -->}}
{{subst:u2w|1=<!-- URL -->|2=<!-- display text -->}}
{{subst:u2w|url=<!-- URL -->|display=<!-- display text -->}}
{{subst:u2w
| url =
| display =
| link =
| section =
| colontrick =
| error =
}}
|link=no
then the colon trick will not be used anyway - this is necessitated by a longstanding bug in Mediawiki.Code | Result |
---|---|
{{subst:u2w|error=no}}
|
|
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Pearl_Jam}}
|
Pearl Jam |
{{subst:u2w|url=https://en.wikipedia.org/w/index.php?title=Pearl_Jam&action=history}}
|
Pearl Jam |
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles}}
|
Wikipedia:Village pump (policy)/Archive 102#Using {{Comment}} on articles |
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles|display=the village pump}}
|
the village pump |
{{subst:u2w|url=https://es.wikivoyage.orgview_html.php?sq=&lang=&q=Bogot%C3%A1#En_avi.C3.B3n}}
|
voy:es:Bogotá#En avión |
{{subst:u2w|url=https://es.wikivoyage.orgview_html.php?sq=&lang=&q=Bogot%C3%A1#En_avi.C3.B3n|link=no}}
|
voy:es:Bogotá#En avión |
{{subst:u2w|url=https://es.wikivoyage.orgview_html.php?sq=&lang=&q=Bogot%C3%A1#En_avi.C3.B3n|display=Bogota by plane}}
|
Bogota by plane |
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Category:Wikipedians}}
|
Category:Wikipedians |
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Category:Wikipedians|colontrick=no}}
|
|
{{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Wikipedia:Village_pump_%28policy%29/Archive_102#Using_.7B.7BComment.7D.7D_on_articles|section=no}}
|
Wikipedia:Village pump (policy)/Archive 102 |
This template will not work correctly if the original section name contains anything that looks percent-encoded. This usually means a period followed by two characters that could be hexadecimal. For example, the code {{subst:u2w|url=https://en.wikipedia.orgview_html.php?sq=&lang=&q=Wikipedia:Sandbox#Pi_equals_3.14}}
produces Wikipedia:Sandbox#Pi equals 3�. To work around this you can set |section=no
and |link=no
, and add the link and the proper section name yourself. However, bear in mind that the actual link will still work properly even if it is displayed incorrectly, so it is not necessary to use the workaround if you also set the |display=
parameter.
Additionally, some Wikimedia sites may not be supported yet. If you come across a site that isn't supported, please consider adding it to Module:InterwikiTable, as then it will work for all users.