For faster navigation, this Iframe is preloading the Wikiwand page for 模板:URL.

模板:URL

文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

本模版用于生成格式化的外部链接。本模板生成的链接会使用<wbr>进行处理,方便浏览器自动换行。

用法

((URL|1=url name|2=optional display text))

  • 第一个参数用于写入相应的URL外链,并对其分析,如果没附带相应的协议名的话,默认添加为“http://”协议头,如果有相应协议头的话,则根据协议头显示相应的连接图标,现支持“ http:// ”,“ https:// ”和“ ftp:// ”三种协议。
  • 第二个参数为可选参数,可以改变链接显示时的名称,若留空,则直接显示连接。
:如果没指定第一个参数的话,第二个参数直接显示填入值,但不生成链接。
  • 如果不填任何参数,则自动生成模板的例子写法。

含有等号的网址

如果网址中含有等号(“=”),需指定参数|1=

  • ((URL | 1=https://example.com/?id=42 ))example.com?id=42
    <span class="url">[https://example.com/?id=42 example<wbr/>.com?id=42]</span>

此时,如果指定标题,第二个参数也需显式标示:

  • ((URL | 1=https://example.com/?id=42 | 2=Title ))Title
    <span class="url">[https://example.com/?id=42 Title]</span>
警告:
  • 强烈建议显式标明参数名来写入参数(尤其链接中有类似等号("=")时),避免错误解释,导致无法显示连接。如果存在第二参数的话,更加需要显式参数名,以免错误覆盖第一参数的值。
  • 如果链接中含有包含问号或井号的查询字符串的话,强烈建议链接后加“/”做结束,以免解释错误,“/”不会被显示出来的,请放心。为防止错误将查询字符串被改变(如小写化),强烈建议使用显式参数名写入参数。

范例

Code Result
(( URL )) ((URL|example.com|可选的显示文本))
(( URL | )) ((URL|example.com|可选的显示文本))
((URL ||example)) example
(( URL | EXAMPLE.com )) example.com
(( URL | example.com )) example.com
(( URL | www.example.com )) www.example.com
(( URL | http://www.example.com )) www.example.com
(( URL | https://www.example.com )) www.example.com
(( URL | ftp://www.example.com )) www.example.com
(( URL | ftp://ftp.example.com )) ftp.example.com
(( URL | http://www.example.com/ )) www.example.com
(( URL | http://www.example.com/path )) www.example.com/path
(( URL | www.example.com/foo )) www.example.com/foo
(( URL | http://www.example.com/foo | link )) link
(( URL | www.example.com/foo | link )) link
(( URL | http://www.example.com/path/ )) www.example.com/path/
(( URL | www.example.com/foo/ )) www.example.com/foo/
(( URL | http://www.example.com/foo/ | link )) link
(( URL | www.example.com/foo/ | link )) link

微格式

The template wraps the displayed URL with a class="url" so that it is included in any parent microformat which takes a URL parameter - see our microformats project.

参见

{{bottomLinkPreText}} {{bottomLinkText}}
模板:URL
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?