How to link to file using relative path?

4,507 views
Skip to first unread message

Khundeen

unread,
Sep 19, 2009, 8:46:45 PM9/19/09
to TiddlyWiki
Hi,

Is it possible to create link to file that is in the same folder as
the tiddlywiki.html using relative path?

I have a folder that contains pdf files and I want to be able to
open pdf file from the wiki page. Right now it works if I use
absolute path. Both file:\\\ and http:\\.

This tag works [[file://path/to/wiki/filename.pdf]]. But [[file://
filename.pdf]] doesn't work.

Ultimately, I would like to set up my wiki so that it works both
online and offline and still be able to access the pdf files. This is
the primary reason why I want to use relative path. This way I can
have a file sync software sync the folder in my local hd with the web
server. I can either access my wiki from the web or locally.

Thanks,
Deen

Eric Shulman

unread,
Sep 20, 2009, 2:42:23 AM9/20/09
to TiddlyWiki
> Is it possible to create link to file that is in the same folder as
> the tiddlywiki.html using relative path?
>
> This tag works [[file://path/to/wiki/filename.pdf]]. But [[file://
> filename.pdf]] doesn't work.

By design, [[anytext]] is always assumed to be a link to a tiddler,
even if that tiddler doesn't exist yet. Fortunately, the "PrettyLink"
syntax, [[text|link]], applies the inverse rule: the link is assumed
to be external, *unless* the tiddler already exists. While this
distinction is subtle, it does allow you to achieve the result you
want:

[[filename.pdf]] is a link to a tiddler, but
[[filename.pdf|filename.pdf]] is a link to an external file

And, because the link doesn't start with an /absolute/path/to/
folder/..., it is automatically handled by the browser as *relative to
the current directory* (i.e, the one containing the TW document).
Thus, you can also write something like:
[[old version|archives/filename.jpg]]
to link to a file in a *relative sub-directory*.

Also note that the link doesn't specify either http:// or file://
protocol. In fact, in most browsers, relative references only work
when you omit the protocol from the URL. In this case, it's an
advantage: it means that the same external PrettyLink can be applied
locally (as a filesystem reference), or remotely (as a server-side
URL), without needing any special TW code... the browser's normal
handling does it automatically.

enjoy,
-e

Eric Shulman

unread,
Jan 25, 2013, 12:24:22 PM1/25/13
to TiddlyWiki
> the path and this command does not work:
> [[my file|file://filename.avi]]
> but with absolute path is works fine [[my file|file:///c:\my
> documents\filedir\filename.avi]]

As I previously explained:
> > And, because the link doesn't start with an /absolute/path/to/
> > folder/..., it is automatically handled by the browser as *relative to
> > the current directory* (i.e, the one containing the TW document).
> > Thus, you can also write something like:
> >    [[old version|archives/filename.jpg]]
> > to link to a file in a *relative sub-directory*.
>
> > Also note that the link doesn't specify either http:// or file://
> > protocol.  In fact, in most browsers, relative references only work
> > when you omit the protocol from the URL.  In this case, it's an
> > advantage: it means that the same external PrettyLink can be applied
> > locally (as a filesystem reference), or remotely (as a server-side
> > URL), without needing any special TW code... the browser's normal
> > handling does it automatically.


> Is it a way to set a variable with the path where the files are located?
> and to use this variable when naming the file to be openned?

http://www.TiddlyTools.com/#ImagePathPlugin

works for [img[...]], but not for general external links.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact

giraf...@gmail.com

unread,
Jan 27, 2013, 12:54:37 PM1/27/13
to tiddl...@googlegroups.com
Thanks Eric for your answer.

I solved in the following way: 

As I used FF, I upload an extension for Firefox:  LocalLink 0.5, ( http://locallink.mozdev.org/ )
and it worked fine.  Also the simple way of placing the filename works with IE, but I did not try with other explorers.

Florencio de la Torre

Tobias Beer

unread,
Jan 27, 2013, 2:38:19 PM1/27/13
to tiddl...@googlegroups.com
Hi Florencio,

Just to make sure, I believe what Eric was trying to convey was that...

[[my file|filename.avi]

...will do the trick for linking to any filename.avi that resides in the same directory as your TW via some link that displayed as [my link].

Cheers, Tobias.

Reinhard Engel

unread,
Jan 25, 2022, 12:44:23 PM1/25/22
to TiddlyWiki
I'm picking up this very old discussion. What is the state of the art? It seems that the proposed solution by Eric Shulman

```
[[filename.pdf]] is a link to a tiddler, but
[[filename.pdf|filename.pdf]] is a link to an external file

And, because the link doesn't start with an /absolute/path/to/
folder/..., it is automatically handled by the browser as *relative to
the current directory* (i.e, the one containing the TW document).
Thus, you can also write something like:
[[old version|archives/filename.jpg]]
to link to a file in a *relative sub-directory*.
```
doesn't work with the current version of TiddlyWiki.

I have exactly the constellation described in this example (see attached screenshot). The two links using a relative path respectively, point to a non-existing internal tiddler. The last link with the fullpath point correctly to the external PDF file.
How can I use relative paths to external files nowadays?


-Reinhard
RelativePath.png

PMario

unread,
Jan 25, 2022, 1:03:53 PM1/25/22
to TiddlyWiki
Did you try: `[[old version|./archives/filename.jpg]]` ?
-m

Reinhard Engel

unread,
Jan 26, 2022, 2:00:25 AM1/26/22
to TiddlyWiki
Yes; it didn't work as well.

By chance I stumpled upon a solution:

As soon as I put the prefix file: before the relative path, everything works as expected. So

```
[[old version|file:archives/filename.jpg]]
```

should do the job.

In my case

```
[[pdf|file:articles/MicroContent with TiddlyWiki.pdf]]
```

does work.

-Reinhard

(I'm using Firefox; didn't test with Chrome.)

Reinhard Engel

unread,
Jan 26, 2022, 2:03:58 AM1/26/22
to TiddlyWiki
Of course, it must read 'I stumbled upon...'

Is there a way to edit one's own posts?

-Reinhard

Eric Shulman

unread,
Jan 26, 2022, 2:20:00 AM1/26/22
to TiddlyWiki
On Tuesday, January 25, 2022 at 11:03:58 PM UTC-8 reinhard...@gmail.com wrote:
Is there a way to edit one's own posts?

Editing your own posts is one of the many features that GoogleGroups has *REMOVED* from their interface.  This steady "decay" in utility of the GoogleGroups interface has led to the creation of an alternative Discourse-based server -- https://talk.tiddlywiki.org/ -- that provides a much richer set of tools.  Many people (though not all) have migrated to using that system as their primary means for engaging with others in the TiddlyWiki community.

-e




 

Reinhard Engel

unread,
Jan 26, 2022, 5:30:42 AM1/26/22
to TiddlyWiki
Thanks Eric! In the future, I will post on the new forum.

-Reinhard
Reply all
Reply to author
Forward
0 new messages