Skip to content

Maintaining portability when using relative links

Arlen22 edited this page Dec 9, 2019 · 1 revision

In single-file wikis, your relative links (e.g. docs/test.png) will refer to folders in the same folder as the wiki is in. When you move to a data folder wiki, your relative links will be broken, because they will now refer to folders INSIDE the data folder, and TiddlyServer gives all requests to the TiddlyWiki instance to handle, which only serves the files folder.

The best way to future proof your relative links is to put each single-file wiki in its own folder, and any files that belong inside the folder should be put in a files folder. This will also allow the data folder to be loaded by itself using the TiddlyWiki listen command, since the files folder IS served by TiddlyWiki.

Files that can be outside the folder will be relative-linked using paths starting with two dots (../). Or you can use absolute links like /personal/hobby/snaps.png, but this requires all your TiddlyServer instances to have the same path setup, which makes it a little less plug-and-play.

To link to a different wiki, you just link to the folder /personal/hobby/datafolder/. But you also need to set the index options on the tree so TiddlyServer knows to serve an index file if it finds one. Here is an example of the tree element with this option specified. The original tree goes under the $children property.

"tree": {
    "$element": "group",
    "$children": {
      "Arlen": "~/Desktop/Random",
      "Dropbox": "~/Dropbox",
      "GitHub": "~/Desktop/GitHub"
    },
    "$options": [
      {
        "$element": "index",
        "indexFile": ["index"],
        "indexExts": ["html", "htm", "hta", "tw"]
      },
      {
        "$element": "auth",
        "authList": null,
        "authError": 403
      }
    ]
  },
Clone this wiki locally