In Trilium, attributes are key-value pairs assigned to notes, providing additional metadata or functionality. There are two primary types of attributes:
In Trilium, attributes are key-value pairs assigned to notes, providing additional metadata or functionality. There are two primary types of attributes:
1. **Labels**: Simple key-value text records
1. <aclass="reference-link"href="Attributes/Labels.md">Labels</a>: Simple key-value text records
2. **Relations**: Named links to other notes
2. <aclass="reference-link"href="Attributes/Relations.md">Relations</a>: Named links to other notes
These attributes play a crucial role in organizing, categorising, and enhancing the functionality of notes.
These attributes play a crucial role in organizing, categorising, and enhancing the functionality of notes.
@ -18,26 +18,22 @@ Labels in Trilium can be used for a variety of purposes:
Labels are also searchable, enhancing note retrieval.
Labels are also searchable, enhancing note retrieval.
### Common Labels for Advanced Configuration
For more information, including predefined labels, see<aclass="reference-link"href="Attributes/Labels.md">Labels</a>.
See the corresponding section in<aclass="reference-link"href="Attributes/Attribute%20Reference.md">Attribute Reference</a>for a comprehensive list of attributes.
## Relations
## Relations
Relations define connections between notes, similar to links.
Relations define connections between notes, similar to links.
### Uses
Uses:
* **Metadata Relationships**: For example, linking a book note to an author note
* **Metadata Relationships**: For example, linking a book note to an author note
* **Scripting**: Attaching scripts to events or conditions related to the note
* **Scripting**: Attaching scripts to events or conditions related to the note
### Common Relations
For more information, including a list of predefined relations, see<aclass="reference-link"href="Attributes/Relations.md">Relations</a>.
See the corresponding section in<aclass="reference-link"href="Attributes/Attribute%20Reference.md">Attribute Reference</a>for a comprehensive list of relations.
## Multiplicity
## Multiplicity
Attributes in Trilium can be "multivalued", meaning multiple attributes with the same name can coexist.
Attributes in Trilium can be "multi-valued", meaning multiple attributes with the same name can co-exist.
Inheritance refers to the process of having a [label](Labels.md) or a [relation](Relations.md) shared across multiple notes, generally in parent-child relations (or anywhere if using templates).
## 1\. Standard Inheritance
## 1\. Standard Inheritance
In Trilium, attributes can be automatically inherited by child notes if they have the `isInheritable` flag set to `true`. This means the attribute (a key-value pair) is applied to the note and all its descendants.
In Trilium, attributes can be automatically inherited by child notes if they have the `isInheritable` flag set to `true`. This means the attribute (a key-value pair) is applied to the note and all its descendants.
### Example Use Case
To make an attribute inheritable, simply use the visual editor for<aclass="reference-link"href="Labels.md">Labels</a>or<aclass="reference-link"href="Relations.md">Relations</a>. Alternatively, the attribute can be manually defined where `#myLabel=value` becomes `#myLabel(inheritable)=value` when inheritable.
The `archived` label can be set to be inheritable, allowing you to hide a whole subtree of notes from searches and other dialogs by applying this label at the top level.
As an example, the `archived` label can be set to be inheritable, allowing you to hide a whole subtree of notes from searches and other dialogs by applying this label at the top level.
A relation is similar to a [label](Labels.md), but instead of having a text value it refers to another note.
## Creating a relation using the visual editor
1. Go to the _Owned Attributes_ section in the<aclass="reference-link"href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Ribbon.md">Ribbon</a>.
2. Press the + button (_Add new attribute_) to the right.
3. Select _Add new relation_ for the relation.
> [!TIP]
> If you prefer keyboard shortcuts, press <kbd>Alt</kbd>+<kbd>L</kbd> while focused on a note or in the _Owned Attributes_ section to display the visual editor.
While in the visual editor:
* Set the desired name
* Set the Target note (the note to point to). Unlike labels, relations cannot exist with a target note.
* Check _Inheritable_ if the label should be inherited by the child notes as well. See<aclass="reference-link"href="Attribute%20Inheritance.md">Attribute Inheritance</a>for more information.
## Creating a relation manually
In the _Owned Attributes_ section in the<aclass="reference-link"href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Ribbon.md">Ribbon</a>:
* To create a relation called `myRelation`:
* First type `~myRelation=@`.
* After this, an autocompletion box should appear.
* Type the title of the note to point to and press <kbd>Enter</kbd> to confirm (or click the desired note).
* Alternatively copy a note from the<aclass="reference-link"href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a>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 `~myRelation` write `~myRelation(inheritable)`.
## Predefined relations
These relations are supported and used internally by Trilium.
> [!TIP]
> Some relations presented here end with a `*`. That means that there are multiple relations with the same prefix, consult the specific page linked in the description of that relation for more information.
<figureclass="table"style="width:100%;"><tableclass="ck-table-resized"><colgroup><colstyle="width:33.95%;"><colstyle="width:66.05%;"></colgroup><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>runOn*</code></td><td>See <aclass="reference-link"href="../../Scripting/Events.md">Events</a></td></tr><tr><td><code>template</code></td><td>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.</td></tr><tr><td><code>inherit</code></td><td>note's attributes will be inherited even without a parent-child relationship. See <aclass="reference-link"href="../Templates.md">Templates</a> for a similar concept. See <aclass="reference-link"href="Attribute%20Inheritance.md">Attribute Inheritance</a> in the documentation.</td></tr><tr><td><code>renderNote</code></td><td>notes of type <aclass="reference-link"href="../../Note%20Types/Render%20Note.md">Render Note</a> 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</td></tr><tr><td><code>widget_relation</code></td><td>target of this relation will be executed and rendered as a widget in the sidebar</td></tr><tr><td><code>shareCss</code></td><td>CSS note which will be injected into the share page. CSS note must be in the shared sub-tree as well. Consider using <code>share_hidden_from_tree</code> and <code>share_omit_default_css</code> as well.</td></tr><tr><td><code>shareJs</code></td><td>JavaScript note which will be injected into the share page. JS note must be in the shared sub-tree as well. Consider using <code>share_hidden_from_tree</code>.</td></tr><tr><td><code>shareTemplate</code></td><td>Embedded JavaScript note that will be used as the template for displaying the shared note. Falls back to the default template. Consider using <code>share_hidden_from_tree</code>.</td></tr><tr><td><code>shareFavicon</code></td><td>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 <code>share_hidden_from_tree</code>.</td></tr></tbody></table></figure>
<li>To create a relation called <code>myRelation</code>:
<ul>
<li>First type <code>~myRelation=@</code>.</li>
<li>After this, an autocompletion box should appear.</li>
<li>Type the title of the note to point to and press <kbd>Enter</kbd> to confirm
(or click the desired note).</li>
<li>Alternatively copy a note from the <aclass="reference-link"href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.html">Note Tree</a> and
paste it after the <code>=</code> sign (without the <code>@</code>, in this
case).</li>
</ul>
</li>
<li>To create an inheritable relation, follow the same steps as previously
described but instead of <code>~myRelation</code> write <code>~myRelation(inheritable)</code>.</li>
</ul>
<h2>Predefined relations</h2>
<p>These relations are supported and used internally by Trilium.</p>
<aside
class="admonition tip">
<p>Some relations presented here end with a <code>*</code>. That means that
there are multiple relations with the same prefix, consult the specific
page linked in the description of that relation for more information.</p>