Nearby Neighbors: A WikiText Solution


Nearby neighbors are a list of tiddlers related to the current tiddler which share some properties. This thread demonstrates a wikitext solution to display the nearby neighbors through a view template at the bottom of each non system tiddler


The below is a WikiText solution in the form of a ViewTemplate tiddler.

Terminology / Parameters

The following metrics enter into the calculation of how “close” a neighbor is.

  • parent: The neighbor is a tag of the current tiddler.
  • child: The neighbor is tagged with the current tiddler.
  • spouse: The neighbor and the current tiddler have at least one child tiddler in common. Each common child contributes the defined weight to the total score.
  • sibling: The neighbor and the current tiddler have a parent tiddler in common. Each common parent contributes the defined weight to the total score.
  • fielded: The neighbor appears in the fieldName field of the current tiddler, or the current tiddler appears in the fieldname field of the neighbor. Which field to use can be set in the fieldName definition at the top. The field is a list field, i.e. tiddler titles must be enclosed in [[brackets]] if they contain spaces.
  • linked: The current tiddler contains a hard link to the neighbor.
  • backlinked: The neighbor contains a hard link to the current tiddler.

The weights for each metric can be set individually in the definitions at the top (larger score means closer neighbor). A weight of 0 means that this particular metric is disregarded. Also, the maximum number of tiddlers to show (numberOfTiddlersShown) and the minimum score required for a neighbor to be listed (minScore) can be defined.

Finally, the exclusions variable contains a filter which causes that tiddler to be removed from the neighbors list if the filter returns any result for a particular tiddler (see Operator).


The list is only shown when there is something to show (neighbors with a score > minScore exist).

The WikiText inside the <li> tag determines the output formatting. In the example below the total score as well as the contributing metrics are shown. The corresponding lines can easily be removed or replaced by icons if required.


You can download the working viewtemplate tiddler here and drop it into any wiki:
neighbors.json (4.3 KB)


To give a try,

  1. Download the viewtemplate tiddller above and drag and drop into
  2. Look at the bottom of HelloThere it looks like this:

It is probably a good idea to set minScore to at least 2, in order to remove simple tags from the output (and raise the childWeight to 2 if you want to keep showing children).

Have a nice day


A demo page has beed added here:

Nearby Neighbors — display neighbors of current tiddlers (

1 Like

@Mohammad: Thank you very much for setting this up. I will try and add explanations for the various terms to the original post today if possible.

1 Like

This is great to see. I will make a new thread for the next update to my plugin – and I will continue that, as I think it’s aimed at a different audience than this. But I love seeing the variety always created by TW community.


I noticed that the neighbors ViewTemplate slowed the wiki down somewhat on a less-powerful machine and located the reason in this filter run within the neighbors SetWidget:


The input to the filter run prefixed with :not are all tiddlers of the wiki, for each of which the filter was calculated (which in my case contained a enlist<fieldedTiddlers> operator, to remove all the tiddlers that are already contained in a different list).
I have replaced this with


which should be functionally equivalent, but operates only on the tiddlers that have previously been enlisted. Now all’s well again.

So I guess one does need to read the docs very carefully, in this case Expression. :sweat_smile:

Have a nice day

PS: I have updated the JSON file, but not @Mohammad’s demo site.


This is tricky!

Nice Boolean operation, it seems one has to know good math to be able to write high performance filters in TiddlyWiki :sweat_smile: :wink: :sweat_smile:

Demo updated to latest version!