Relations
A relation is similar to a label, but instead of having a text value it refers to another note.
Common use cases
- Metadata Relationships for personal use: For example, linking a book note to an author note.
This can be combined with Promoted Attributes to make their display more user-friendly. - Configuration: For configuring some notes such as Render Note, or configuring Sharing or Templates (see the list below).
- Scripting: Attaching scripts to events or conditions related to the note.
Creating a relation using the visual editor
- Go to the Attributes tab in the Right Sidebar.
- Press the button (Add a new attribute) to the right of the Owned attributes section.
- Select Add new relation for the relation.
While in the visual editor, set the desired name and the Target note (the note to point to). Unlike labels, relations cannot exist with a target note.
Children can inherit this relation, click the relation and check Inheritable. See Attribute Inheritance for more information.
Creating a relation manually
In the Status bar, press the button to show the list of the attributes.
- To create a relation called
myRelation:- Click the input box to focus it.
- Type
~myRelation=@. - After this, an autocompletion box should appear.
- Type the title of the note to point to and press Enter to confirm (or click the desired note).
- Alternatively copy a note from the Note Tree and paste it after the
=sign (without the@, in this case).
- To create an inheritable relation, follow the same steps as previously described but instead of
~myRelationwrite~myRelation(inheritable).
Predefined relations
These relations are supported and used internally by Trilium.
| Label | Description |
|---|---|
runOn* | See Backend Events |
template | note's attributes will be inherited even without a parent-child relationship, note's content and subtree will be added to instance notes if empty. See documentation for details. |
template:newNoteDefaultParent | set on a template note, points to the note under which notes created from the template are placed when no other location is picked; when set several times, the note is cloned into every target. See Templates. |
inherit | note's attributes will be inherited even without a parent-child relationship. See Templates for a similar concept. See Attribute Inheritance in the documentation. |
renderNote | notes of type Render Note will be rendered using a code note (HTML or script) and it is necessary to point using this relation to which note should be rendered |
widget | Used in the context of custom Launch Bar Widgets, to refer to the widget that will be rendered. |
shareCss | CSS note which will be injected into the share page. CSS note must be in the shared sub-tree as well. Consider using shareHiddenFromTree and shareOmitDefaultCss as well. |
shareJs | JavaScript note which will be injected into the share page. JS note must be in the shared sub-tree as well. Consider using shareHiddenFromTree. |
shareHtml | HTML note which will be injected into the share page at locations specified by the shareHtmlLocation label. HTML note must be in the shared sub-tree as well. Consider using shareHiddenFromTree. |
shareTemplate | Embedded JavaScript note that will be used as the template for displaying the shared note. Falls back to the default template. Consider using shareHiddenFromTree. |
shareFavicon | Favicon note to be set in the shared page. Typically you want to set it to share root and make it inheritable. Favicon note must be in the shared sub-tree as well. Consider using shareHiddenFromTree. |
docxTemplate | Word document (a File note) that the note is written into when it is exported as a Word document, taking its styles, headers, footers and page setup. Typically made inheritable. See Import & Export. |