Using templates to create external links

I wanted to set up a template to render and external link where the title of the tiddler is the regular “clickable link” and a field called link is the actual link to go to.

I have this in my “JobFolder” template

[ext[ {{!!title}} | file:///{{!!link}} ]]

But all that is rendered is a literal {{!!title}} underlined in blue linking to file:///{{!!link}}

In a tiddler that I want to put through this template, I have

{{||JobTemplate}}

Each of {{!!title}} and {{!!link}} display fine on their own, but that’s not what I want.

Hopefully I’m missing something silly.

Check the “Generating dynamic links” section of this tiddler: https://tiddlywiki.com/#Linking%20in%20WikiText. The information there should help.

Edit: oops you ask about external links and my answer is about tiddler links. You should be able to use the <a href=... format for links as described at https://tiddlywiki.com/#HTML%20Links%20in%20WikiText

1 Like

When you want to manipulate the values in wiki text such as in this case the [ext[]] stop using the shortcut form and look for the expanded form.

  • This is a common error, where people take the simplest limited form and try to make it more complex, when you may just abandon the simple form, and look for the extended form.

For example rather than [img[]] use <$image>, rather than use {{tiddler}} use <$transclude ../> and as @btheado you can use the html “a” tag.

  • Another option here is creating a tiddler to represent the external resource and give it a _canonical_uri field.
    • This permits that tiddler to be tagged and listed etc… even although it represents an external resource.
    • This is superior to hard coding the link in a tiddlers content. It becomes a reusable resource, if represented by a tiddler.

Thanks both, I’ve got this working now with your suggestions. I will use

<a href={{!!link}}} target="_blank">{{!!title}}</a>

for now. The _canonical_uri looks intresting though what I’m linking to is a directory so I’m not sure what content-type applies. Also I don’t want the content displayed in the tiddler. The tiddlers where with this template is use are just for displaying the link to click into. I will keep it in mind though!

Have a good day!