Data attributes

A Splitleaf page is plain HTML. A small set of data-* attributes is the template language: components, content lists, bindings and a few build hints. The Design panel writes these attributes for you. You can also write them by hand.

There are three kinds:

KindExampleAt publish
Markersdata-opt-, data-bind-, data-prop-*The build reads them, then removes them
Live hooksdata-link-type, variant attributes, filter formsKept, because CSS or a script on the live site uses them
App-onlydata-opt-ui, data-opt-ui-idNever in a site file. The App removes them when it saves.

JSON values sit inside attributes. In a file they are HTML-escaped ("). The examples here use single quotes, which is also valid HTML.

For the component attributes (data-opt-component, data-opt-instance, data-prop-*), see Component files.

Content lists

A list of items needs three levels: a content block, a list and an item.

<div data-opt-dynamic="blog">
  <div class="post-list" data-opt-list="latest-posts"
       data-opt-query='{"sort":[{"field":"publishedAt","dir":"desc"}],"limit":3}'>
    <a class="post-row" data-opt-item data-bind-attr="href:@url">
      <time data-bind-text="publishedAt" data-bind-format="date:medium">Date</time>
      <span data-bind-text="title">Title</span>
    </a>
  </div>
</div>

The build repeats the item once for each post. The live HTML has no markers:

<div>
  <div class="post-list">
    <a href="/blog/welcome-to-northlight" class="post-row">
      <time datetime="2026-09-20">Sep 20, 2026</time>
      <span>Welcome to Northlight</span>
    </a>
  </div>
</div>
AttributeGoes onValue
data-opt-dynamicA wrapper around the listThe collection folder name, for example blog
data-opt-listThe listAn ID, unique on the page
data-opt-queryThe listJSON: filter, sort, limit and start. No value means every item.
data-opt-itemA direct child of the listNo value. The build repeats it for each item.

A list takes its collection from the nearest data-opt-dynamic above it. A list inside an item of another list repeats for each outer item, three levels deep at most.

The query

{ "filter": { "op": "and" | "or", "rules": [ { "field", "cmp", "value" }, … ] },
  "sort":   [ { "field": "publishedAt", "dir": "asc" | "desc" | "random" } ],
  "limit":  3,
  "start":  0 }

The build filters, then sorts, then skips start, then takes limit.

ComparatorsFor
eq, neq, contains, not-contains, starts-with, ends-withText. Case does not matter.
gt, gte, lt, lteNumbers
before, afterDates
is-true, is-falseSwitches
is-set, is-not-setA value, or no value
in, includesA value in a list, or a list that holds the value
ref-eq, ref-current, ref-not-currentReference fields

Bindings

AttributeValueWhat it does
data-bind-textFieldSets the text of the element
data-bind-htmlA Markdown or rich text fieldSets the inside of the element as HTML
data-bind-attrattr:field pairs, joined by ;Sets attributes, for example href:@url; src:coverImage
data-bind-attr-templateJSON, for example {"aria-label":"Read ${title}"}Sets an attribute from text mixed with fields
data-bind-formatdate:short, date:medium, date:long, date:full, datetime:…, time:…, number:0 to number:3Formats a date or a number in the language of the page
data-bind-rollup<list id>:count, or <list id>:sum:<field> (also avg, min, max)Sets the text to a count or a sum over a list
Field pathGives
title, excerpt, …A field from _collection.json
@urlThe URL of the item page
@slugThe slug of the item
@idThe item ID
author.titleA field of the item that a reference field points to

Bindings work in a list item and on a content template. Outside of these, the build removes the marker and the placeholder text ships.

Display rules

data-opt-display shows or hides an element by a rule. Use it for an empty state, or to hide an image when an item has none.

<picture data-opt-display='{"groups":[{"match":"all","visibility":"visible",
  "conditions":[{"source":"field","field":"coverImage","op":"is-set"}]}],"else":"hidden"}' hidden>
  <img alt="" data-bind-attr="src:coverImage">
</picture>
Condition sourceExample
field{ "source": "field", "field": "coverImage", "op": "is-set" }
list{ "source": "list", "list": "latest-posts", "op": "is-empty" }
filter{ "source": "filter", "op": "no-results" }. The browser decides this one.

At publish the build removes a rule it can decide. It removes a hidden element with it.

Filters

A form that filters a list in the browser.

<form data-opt-filter="latest-posts">
  <input type="search" data-opt-filter-field="title" data-opt-filter-cmp="contains">
</form>
AttributeGoes onValue
data-opt-filter<form>The data-opt-list ID of the list
data-opt-filter-fieldA control in the formA field, or * for the slug and every plain field
data-opt-filter-cmpThe same controlA comparator. The default is eq.

These attributes ship. The build adds an index of the rows and <script src="/opt-filter.js" defer>. Only pages with a filter form get the script.

Build hints

AttributeGoes onValue
data-opt-compressAn <img> from /assets/on or off. No attribute: the site setting.
data-opt-qualityThe same <img>50 to 95. No attribute: the site setting.
data-opt-richtext<div class="rich-text">Marks a Rich text element. The Design panel edits its inside as one piece.

The build removes all three. For the image settings, see Images.

The page head

TagWhat it does
<meta name="splitleaf:status" content="draft">The page status: draft or archived. No tag: published.
<link rel="canonical">Your canonical wins. With no tag, the build makes one from the site URL.
<meta name="robots" content="noindex">Also keeps the page out of sitemap.xml

The build adds og:type, og:url, og:locale, hreflang links and favicon links. It also writes <meta name="generator" content="Splitleaf">.

Attributes that ship

AttributeWritten by
data-<axisKey>, for example data-tone="dark"Component variants
data-link-typeThe link settings: internal, external, section, email, telephone, download
data-themeTheme blocks in styles/variables.css, for example [data-theme="dark"]
data-opt-filter, data-opt-filter-field, data-opt-filter-cmpFilter forms
data-splitleaf-list-emptyThe build, on a list with no items, so CSS can style the empty state

Caution: Do not write data-opt-ui or other data-opt-ui-* attributes in a site file. The App uses them only in the Design panel. If one reaches a file, it ships.