Link()
Renders an HTML-link (<a> tag).
Supported link-types: mail, pdf, sms, tel, geo, gsm, slack, twitter, tiktok, instagram, facebook.
link()
Renders an HTML-link (<a> tag).
Supported link-types: mail, pdf, sms, tel, geo, gsm, slack, twitter, tiktok, instagram, facebook.
Arguments
- url
- Path or URL to link target (default: false)
- text
- Link-text. If missing, "href" will be displayed instead. (default: false)
- type
- [intern, extern or mail, pdf, sms, tel, gsm, geo, slack] "mail" renders link as "mailto:", "intern" suppresses automatic prepending of "https://", "extern" causes link target to be opened in new window. (default: false)
- id
- ID to be applied to the <a> Tag. (default: false)
- class
- Class to be applied to the <a> Tag. (default: false)
- title
- Title attribute to be applied to the <a> Tag. (default: false)
- icon
- Icon to be added to the link text.
- iconPosition
- [before,after] Where to add the icon. (default: before)
- attr
- Generic attribute applied to the <a> Tag. (default: false)
- download
- If true, just adds "download" to tag attributes. (default: false)
- hiddenText
- Text appended to "text", but made visually hidden. I.e. text only available to assistive technologies. (default: false)
- target
- [newwin] Target attribute to be applied to the <a> Tag. "newwin" means opening page in new window (or tab).
- subject
- In case of "mail" and "sms": subject to be preset. (default: false)
- body
- In case of "mail": mail body to be preset. (default: false)
- href
- Synonyme for "url" (default: false)
Examples
{{ link('~/transvars/built_in_macros/link') }}
Link()
→ This link points to a page of this site and no text is defined, thus the page-name is used.
{{ link('https://getkirby.com') }}
getkirby.com
Note:
Because this is a link pointing to another website, it is marked with an "external" icon.
You can disable this feature via config option 'externalLinksToNewWindow' => false.
Note:
The icon automatically adopts the text color (here dark red to show the effect).
Link Text
{{ link('https://getkirby.com', text:"Kirby Doc") }}
Kirby Doc
Icon Position
{{ link('https://pagefactory.info', text:"PageFactory Doc", iconPosition:after) }}
Link Types
The img() macro supports a number of link types. The type is determined:
- explicit type argument, e.g. type:geo
- proto prefix to the link address, e.g. slack:
- implicitly derived from file extension
Code | Result |
---|---|
{{ link('www.getkirby.com', Kirby) }} | Kirby |
{{ link('slack:SLACK') }} | SLACK |
{{ link('tel:0123456789') }} | 0123456789 |
{{ link('gsm:0123456789') }} | 0123456789 |
{{ link('sms:0123456789') }} | 0123456789 |
{{ link('mailto:name@domain.net') }} | name@domain.net |
{{ link('name@domain.net') }} | name@domain.net |
{{ link('geo:46.32776, 7.72283') }} | 46.32776, 7.72283 |
{{ link('test.pdf') }} | test.pdf |
{{ link('pdf:test.pdf') }} | test.pdf |
{{ link('twitter:twitter.com') }} | twitter.com |
{{ link('facebook:facebook.com') }} | facebook.com |
{{ link('instagram:instagram.com') }} | instagram.com |
{{ link('tiktok:tiktok.com') }} | tiktok.com |
{{ link('~/download/sample spreadsheet.xlsx') }} | sample spreadsheet.xlsx |