Is it possible to use pre-defined parts into hyperlink addresses?

Operating system

Windows

Joplin version

3.1.20

What issue do you have?

I have a knowledge base - a directory storing lots of saved articles from the Internet (HTML, PDF, DOCx, etc).
I would like to refer to them from several notes.
I do not want to synchronize them and I do not want to "embed" them into notes. I prefer to keep them separately.
I just want to link link to them.

BUT, when I move to another computer (say, with Linux), where I have a similar directory (synchronised via DropBox), something like "file:///c:/abc/kb/" won't work.

It would work, however, if the link was defined like "file:///RES_DIR/kb" for example,
where the RES_DIR could be defined somewhere in Joplin and automatically "expanded".

I found a plugin: NoteVariables. It does exactly what I need, except that the variables are not "expanded" in hyperlinks.
I mean - they are properly expanded and displayed in the RMD viewer (right panel), but when I define a link with that variable, it remains as is: "file:///RES_DIR/kb" rather than, say "file:///c:/tmp/kb" or "/file:///home/kb".

Is there, maybe, any already existing Joplin mechanism to define such dynamic links, so, when I switch to my other computer, I can just change the variable and all my links will be automatically working? (translated "at runtime")?

You could use the OS symlinks and create the same link on both computers, but it looks like you want compatibility between Windows and Linux so I'm not sure it's possible to create equivalent file:// links on both systems.

Windows file paths can have many different forms though so maybe one of them would work for you. Other than that there's currently no built-in way to do this in Joplin.

Thank you very much for remembering me the idea of symlinks!
I will definitely use it to simplify the process.

At the same time it turned out that... the solution was pretty easy and I didn't even expect this would work :slight_smile:

Although skipping the drive part isn't recognized by Windows Explorer (and also Firefox, Edge):

BUT it works with Joplin! [test](file:///home/adrian/test.txt)

So... I can put the content of my KB directory under some common location (or create appropriate symlink) and it should work :slight_smile:

2 Likes