Template helper link


Generates links using urls or localisation keys, prefixing with domain if necessary.

Accepts protocol-less URLs and email addresses


  • a i18n key/value pair: "foo.href=/foo"
  • the current hostname: "http://domain"

    {{#link "/foo"}}Bar{{/link}}
       -> '<a href="http://domain/foo" target="external">Bar</a>'

Specify a different target

  {{#link "/foo" target="newtarget"}}Bar{{/link}}
     -> '<a href="http://domain/foo" target="newtarget">Bar</a>'

Specify no target

  {{#link "/foo" target=""}}Bar{{/link}}
     -> '<a href="http://domain/foo">Bar</a>'

Pass content explicitly

  {{link "/foo" content="Bar"}}
     -> '<a href="http://domain/foo" target="external">Bar</a>'

Use a i18n key

  {{#link "foo.href"}}Bar{{/link}}
     -> '<a href="http://domain/foo" target="external">Bar</a>'

URLs with a protocol {{#link "https://externaldomain/foo"}}Bar{{/link}} -> 'Bar'

Protocol-less URLs

  {{#link "//anotherdomain/foo"}}Bar{{/link}}
     -> '<a href="//anotherdomain/foo" target="external">Bar</a>'

But if context contains {isMail: true}

  {{#link "//anotherdomain/foo"}}Bar{{/link}}
     -> '<a href="https://anotherdomain/foo" target="external">Bar</a>'

Email addresses

  {{#link "foo@domain"}}Bar{{/link}}
     -> '<a href="mailto:/foo@domain">Bar</a>'
Name Type Attributes Description
0 string

String to use for URL

target string <optional>

Window target for URL - defaults to "external"

content string <optional>

Content of the link - supercedes any yielded value