Skip to content

Trilium Attributes

Overview

Attributes in Trilium are key-value pairs that can be attached to notes to provide additional metadata, categorization, and functionality. The TriliumNext PowerShell Module provides a comprehensive set of functions to manage these attributes programmatically.

Authentication Required

All attribute functions require authentication to your Trilium instance using Connect-TriliumAuth before use.

What are Trilium Attributes?

Trilium supports two types of attributes:

  • Labels: Simple key-value pairs that store metadata about notes
  • Relations: Links between notes that establish relationships

Attribute Types

  • Labels are used for categorization, tagging, and storing simple metadata
  • Relations create connections between notes, enabling complex note hierarchies and cross-references

Available Functions

The module provides the following functions for attribute management:

Core Functions

Function Description
Get-TriliumAttribute Retrieves details of a specific Trilium attribute
New-TriliumAttribute Creates or updates a Trilium attribute (label or relation) for a note
Set-TriliumAttribute Updates properties of an existing attribute (value for labels, position for both)
Remove-TriliumAttribute Removes a specific Trilium attribute

Common Use Cases

Creating Labels

# Add a simple label
New-TriliumAttribute -NoteID "abc123" -Name "status" -Value "published"

# Add an inheritable label
New-TriliumAttribute -NoteID "abc123" -Name "theme" -Value "dark" -IsInheritable

Creating Relations

# Create a relation between notes
New-TriliumAttribute -NoteID "abc123" -Name "relatedTo" -Value "def456" -Type "relation"

Managing Attributes

# Get attribute details
Get-TriliumAttribute -AttributeID "attr123"

# Update attribute value (labels only)
Set-TriliumAttribute -AttributeId "attr123" -Value "new value"

# Update attribute position
Set-TriliumAttribute -AttributeId "attr123" -Position 5

# Remove an attribute
Remove-TriliumAttribute -AttributeID "attr123"

Best Practices

Attribute Naming

  • Use descriptive, consistent names for your attributes
  • Consider using a naming convention (e.g., category:subcategory)
  • Avoid spaces in attribute names when possible

Inheritable Attributes

Use the -IsInheritable flag carefully as these attributes will be passed down to child notes