Relation objects represent typed and untyped relationships between indexed objects in the space. They are the source of truth for relationship queries (graph views, backlinks of non-page objects, typed-attribute edges). The legacy link collection is now a virtual projection over relation.
Attributes
from: ref to the source object: the innermost indexed object that contains the markup producing the edge (page, item, nested item, or fenced#tagblock object). When the source item carries a$anchorthe anchor name is used (matching the item’s own ref), otherwise the source’s byte-offset form (page@pos) is used.fromTag: tag of the source object, denormalized for graph queries.to: ref to the target object.toTag: the target type — one ofpage,anchor,document,url. Set for every resolved edge (absent for unresolved refs).urlis a built-in target tag, likedocument(a real object type) andanchor(a meta-tag).kind: the edge label. Either a reserved structural value —mentionorco-mention— or a user predicate (e.g.spouse,team) taken from a frontmatter key, inline[key: ...]attribute, or#tagdata block key. See Kinds below.via: forco-mentionentries only: ref to the containing item or paragraph that scopes the co-occurrence.page: page where the edge was discovered (used for invalidation).range:[start, end]byte offsets of the wikilink / markdown-link / attribute-value syntax withinpage. Always present. Forco-mentionrecords (which are derived) this points at the source-side wikilink. Used by the rename refactor to splice text.alias: when the source form is[[ref|alias]], the alias. Required to faithfully reproduce the link on rewrite.snippet: contextual text around the edge where available.pageLastModified: last-modified timestamp of the source page, useful for ordering.
Kinds
mention: a plain wikilink or markdown link (to a page, file, anchor, or external URL — seetoTag).co-mention: two refs co-occurring in the same item (with its nested children) or paragraph. Emitted in both directions and dedup’d at the innermost shared scope.- user predicates: any other
kindvalue is a typed attribute edge whose label is the key (e.g.spouse).from/fromTagindicate whether it came from frontmatter, an inline attribute, or a data block.
Examples
Here’s a tagged item to use as an example:
- contact $pete-ref Pete [spouse: “Angela”] [team: “Super Team”]
Show every relation related to $pete-ref (including this one 👈):
${query[[ from r = index.relations() where r.from == “pete-ref” or r.to == “pete-ref” select table.select(r, “from”, “fromTag”, “kind”, “to”, “toTag”) ]]}
All relations defined on this page: ${query[[ from r = index.relations() where r.page == “Object/relation” select table.select(r, “from”, “fromTag”, “kind”, “to”, “toTag”, “snippet”) ]]}