Sorting
Revela supports flexible sorting of galleries and images. You can configure:
- Gallery order in navigation (ascending/descending)
- Image order within galleries (by any field including EXIF data)
- Per-gallery overrides via front matter
Global Configuration
Configure sorting in project.json:
{
"generate": {
"sorting": {
"galleries": "asc",
"images": {
"field": "dateTaken",
"direction": "desc",
"fallback": "filename"
}
}
}
}
| Property | Description | Default |
|---|---|---|
galleries |
Gallery sort direction: asc or desc |
asc |
images.field |
Field to sort images by | dateTaken |
images.direction |
Image sort direction: asc or desc |
desc |
images.fallback |
Field used to order photos that have no value for images.field |
filename |
The same image sort applies to folder galleries, filter galleries and [[gallery]] blocks without their own | sort clause.
Photos Without a Value
Photos that have no value for the sort field (for example no EXIF date, or no rating) always come last, whether you sort asc or desc. Among themselves they are ordered by the fallback field in the same direction, and the file name breaks any remaining tie.
Available Sort Fields
| Field | Description |
|---|---|
filename |
File name (alphabetical) |
dateTaken |
EXIF capture date |
exif.focalLength |
Focal length in mm |
exif.fNumber |
Aperture (f-number) |
exif.exposureTime |
Shutter speed |
exif.iso |
ISO sensitivity |
exif.make |
Camera manufacturer |
exif.model |
Camera model |
exif.lensModel |
Lens model |
rating |
XMP star rating (Capture One, Lightroom); unrated photos last |
title |
Photo title (XMP, else Windows title) |
exif.raw.Copyright |
Copyright field |
exif.raw.{FieldName} |
Any EXIF field from Raw dictionary |
Per-Gallery Override
Override the global sort settings for individual galleries using front matter in _index.revela:
Format:
sort = "field" # Use field, direction from global config
sort = "field:asc" # Use field with ascending order
sort = "field:desc" # Use field with descending order
Examples:
+++
title = "Lens Comparison"
sort = "exif.focalLength:asc"
+++
Compare shots from wide-angle to telephoto.
+++
title = "Best Shots"
sort = "rating:desc"
+++
My highest rated photos.
+++
title = "Timeline"
sort = "dateTaken:asc"
+++
Photos in chronological order (oldest first).
+++
title = "Latest Work"
sort = "dateTaken:desc"
+++
Most recent photos first.
Gallery Order with Number Prefixes
Control gallery order in navigation by adding number prefixes to folder names:
source/
├── 01 Weddings/ # Appears first
│ └── *.jpg
├── 02 Portraits/ # Appears second
│ └── *.jpg
├── 03 Landscapes/ # Appears third
│ └── *.jpg
└── 99 Archive/ # Appears last
└── *.jpg
How It Works
- Prefix format: 1-2 digit number followed by a space (e.g.,
01,2,99) - Display name: Number prefix is automatically removed
01 Weddings→ displayed as "Weddings"99 Archive→ displayed as "Archive"
- URL slug: Number prefix is stripped from URLs
01 Weddings→/weddings/
- Natural sorting: Uses natural order (1, 2, 10 instead of 1, 10, 2)
Year Prefixes Are Preserved
Four-digit year prefixes are NOT stripped (they're meaningful content):
source/
├── 2024 Summer/ # Displayed as "2024 Summer"
├── 2023 Fall/ # Displayed as "2023 Fall"
└── 2022 Winter/ # Displayed as "2022 Winter"
Combining with galleries Setting
The galleries setting controls sort direction:
{
"generate": {
"sorting": {
"galleries": "desc"
}
}
}
With desc:
01 Weddings→99 Archivebecomes99 Archive→01 Weddings- Year folders: 2024 → 2023 → 2022
CLI Configuration
Configure sorting interactively or via command line:
# Interactive wizard
revela config sorting
# Set image sort field
revela config sorting --field dateTaken --direction desc
# Sort by rating
revela config sorting --field rating --direction desc
# Sort by focal length
revela config sorting --field exif.focalLength --direction asc
# Change gallery order
revela config sorting --galleries desc
Logic Flow
- No front matter
sort→ Use global config (generate.sorting.images) sort = "field"→ Override field, keep global directionsort = "field:direction"→ Override both field and direction- Photos without a value for the sort field come last, ordered by the fallback field
- Fallback is always from global config (not overridable per gallery)
- Final tie-breaker is always filename (for stable sorting)