Example 23: Counter Source

The Problem

SSI block includes are great for repeating a template. But when you include the same block multiple times, every instance gets identical content — because all instances resolve the same tokens the same way.

<!-- Page includes the same block three times -->
🪪photo-card
🪪photo-card
🪪photo-card

<!-- But blocks/photo-card.html uses tokens like 📊title -->
<!-- All three cards show the same title! -->
            

The Counter Solution

A counter step runs after the block step. It finds every 🔂name token and replaces it with an incrementing number: 1, 2, 3, and so on.

Blocks can include a counter token adjacent to a data token, forming a composite key. 📊title🔂num becomes 📊title1, then 📊title2, then 📊title3. A subsequent data step resolves these numbered keys from TOML.

Step order is critical: blocks first (to expand the template), then counter (to number the occurrences), then data (to resolve the numbered keys).

What the Other Pages Show

Basic Demo
Three photo cards, each showing different title and caption — one block template, one counter step, one TOML data step.
Advanced
Peek syntax (🔂_name) for reading a counter without incrementing it, and multiple independent counters on one page.
Combined
The same gallery data rendered with include templates instead of counters — a side-by-side comparison of when each approach is the right tool.