Skip to content

Meta Formatting

flarom edited this page Nov 21, 2025 · 1 revision

Default metadata block

title: ~{1:${getFileTitle(index) || "New document"}}
authors: ~{2:Author name}
date: ${strftime(Settings.getSetting("dateFormat", "%Y/%m/%d %H:%M"))}
tags: ~{3:Uncategorized}
description: ~{4:No description provided}
color: ${'#'+Math.floor(Math.random()*16777215).toString(16).padStart(6,'0')}
banner: cohesion/banners/1.png
icon: 

Cohesion supports two special syntaxes inside the document metadata block:

  • Constant value: value as plain text
  • Editable value: ~{n:defaultValue}
  • Executable script as value: ${code}

These are processed by the editor before the metadata block is inserted.

1. Constant value

A constant value is preserved exactly as written and is not modified by Cohesion during metadata insertion. This kind of value is useful for fields that rarely change or are meant to be fixed, such as an author's name or a predefined banner path. When the editor encounters a plain text value, it simply copies that text into the metadata block as is, without additional processing.

author: T. Kasane

2. Editable value: ~{n:value}

Editable values allow the editor to prefill fields while also preparing them for rapid user input. The number preceding the colon determines the order in which the editor selects these fields when entering metadata editing mode and the text after the colon acts as the default value.

title: ~{1:First value}
description: ~{2:Second value}

3. Executable script value: ${code}

Script-based values allow a metadata field to be generated dynamically through JavaScript executed at insertion time. When the editor encounters a ${...} expression, it evaluates the code and replaces the entire field value with the result.

Basic examples

Automatic date timestamp

date: ${strftime("%Y/%m/%d %H:%M")}

Random color for document theming

color: ${'#' + Math.floor(Math.random()*16777215).toString(16).padStart(6,'0')}

This generates a random hexadecimal color string such as #a4d3f0.

Dynamic title derived from the file’s headers

title: ~{1:${getFileTitle(index) || "Untitled document"}}

This attempts to extract a title automatically, falling back to a default. This script is also wrapped as a editable value, so it can also be rapidly edited by the user.

Additional examples

Note

These examples are not supported by Cohesion.

Universally unique identifier for the document

uuid: ${crypto.randomUUID()}

Insertion of the current UNIX timestamp

timestamp: ${Date.now()}

Day of the week

weekday: ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][new Date().getDay()]}

Copyright stamp

copyright: © ${new Date().getFullYear()} ~{1: Copyright Holder}

Learn the basic syntax of markdown and the Cohesion flavored markdown

Learn more advanced markdown applications

Learn how to use metadata on your documents to better organize your files

Learn how to create scripts and automation inside of Cohesion documents

Learn how to use commands to speed up your writing

Clone this wiki locally