David Hellyer Sign out Sign in

Page scan

Scan a directory and return page metadata as a TT array variable.

Page scan

The scan: prefix in tt_page_var scans a directory for .md files and returns an array of page objects. Use it to build indexes, listings, and navigation from page metadata.

Syntax

---
tt_page_var:
  pages: scan:/blog/*.md sort=date desc
---

Pattern rules

Page object fields

Each scanned page returns these fields:

Sort modifier

Append sort=FIELD DIRECTION to the pattern:

scan:/blog/*.md sort=date desc
scan:/docs/*.md sort=title asc
scan:/pages/*.md sort=filename asc

Supported fields: date, title, filename. Default: filename asc. Direction is optional and defaults to asc.

Example

---
title: Blog
tt_page_var:
  posts: scan:/blog/*.md sort=date desc
---
[% FOREACH post IN posts %]
### [% post.title %]

*[% post.date %]* - [% post.subtitle %]

Read more
[% END %]

Notes