How to add field value in a link?

Hi,
I’m still a novice user, so this question might have a very straightforward answer!
I’ve defined a field named bb_volume in a tiddler with e.g. the value 28.
I want this to appear in a link like [[MyLink|file:/my/local/path/bb28]].
I tried using {{!!bb_volume}} but that doesn’t seem to work!
Gerard

Welcome to the community @Gerard!

TW uses a mix of different syntaxes and their shortened variants, so it’s quite common for the newcomers to get lost, don’t worry.

If you use the link wikitext syntax, e.g. [[Example Link|https://example.com]], both the displayed alias and the link itself (be it tiddler name or external URL) have to be literal, they cannot contain any “variable” parts.

When some shortcut syntax is too limited for your needs, you usually want to use the underlying widgets. In this case, link widget (if linking to a tiddler) or html element a (if linking to an external URL).
Then you can insert “variable” target or displayed text of the link.

In your example it could be:

<a href=`file:/my/local/path/bb${ [{!!bb_volume}] }$`>My File</a>

This is one of the shortest ways to do this, but might seem obscure. It uses the substituted attribute value, so that you can substitute a part of the href attribute’s value.
${ }$ substitutes the result of a filter expression.
[{!!bb_volume}] is a filter expression that returns the contents of the bb_volume field of the current tiddler.

To make it a bit more understandable and reusable, you could do something like this:

<$let base-url="file:/my/local/path/bb" volume={{!!bb_volume}} >
    <a href=`$(base-url)$$(volume)$`>My File</a>
</$let>

Here, you first store the base url and the volume in variables, so that they are easier to use in the substituted attribute value.

This is sure a lot at once, but these are very common structures in TW, understanding them will give you a lot of freedom. The links above lead to relevant documentation.
Feel free to ask if you have further questions!

2 Likes

Grok TiddlyWiki has a chapter that covers exactly this topic: Grok TiddlyWiki — Build a deep, lasting understanding of TiddlyWiki

2 Likes

Hi,
Thanks for responding to my first issue with TW!
Mateusz your clear answer is really very helpful; and you encourage me to go on with TW.
And your advice vuk to turn to Grok TiddlyWiki for a deeper understanding is very thoughtful too.
I’ll continue with using tiddlywiki for designing a searchable index for an information sheet that is being published every month in our village.

There is an added advantage here, I browse here for answers for problems I have not encountered yet, and the extremely clear answers help a lot.

And I can recommend Grok too. It is very informative.