You can embed YAML data in a page with a fenced code block. Each block becomes one or more queryable objects.

Defining your own root tags

Use a hashtag as the block's language, and every object in it gets that name as its root tag. This is how you define a new kind of object in plain Markdown:

$ref: pete-contact
name: Pete
age: 55

These objects can be queried via the contact tag: ${queryfrom index.objects("contact")}

Built-in tag names are taken: a ```#task block would look like a real task, so it is not indexed, and lint flags it.

Plain data blocks

A block with data as its language holds objects with the built-in data root tag:

name: Hank
age: 61

Several objects per block

Separate objects with a --- line:

name: Linda
---
name: Jack

Attributes

Every YAML key becomes an attribute, except the ones the index manages itself: ref, tag, itags, page, pos and range.

  • $ref: gives the object a named anchor to use as its ref, so it can be linked to and looked up.
  • tags: user tags for the object, as a list or a string like friend, neighbor.
  • itags always includes data, whichever root tag the object has.

Querying

index.data() returns every data object, whichever block it comes from. Pass a tag to narrow it down, e.g. index.data("contact"):

${queryfrom index.data() where page == _CTX.currentPage.name select {tag=tag, name=name}}