Template filters
The helper functions Project Broadsheet registers with Eleventy. Use them inside any Nunjucks template with the pipe syntax (`{{ value | filter }}`).
Filters are small, reusable helper functions you call from templates with a pipe: {{ my_value | my_filter }}. Project Broadsheet registers a set of filters useful for publishing. They're all defined in eleventy.config.js and available in every template.
Built-in filters
| Filter | Purpose | Example |
|---|---|---|
year | Current four-digit year | `{{ '' |
readableDate | Format a date as "April 17, 2026" | `{{ post.date |
htmlDateString | Format a date as YYYY-MM-DD | Used in <time> elements |
head | First N items of an array | `{{ collections.posts |
striptags | Remove HTML tags | Useful for RSS descriptions |
readingTime | Estimate minutes to read | `{{ content |
rejectattr | Filter an array by attribute | `{{ posts |
truncate | Trim to N characters | `{{ description |
slugify | Convert text to a URL slug | `{{ title |
where | Filter an array by key/value | `{{ docs |
split | Split a string into an array | `{{ "a,b,c" |
Adding a custom filter
Open eleventy.config.js and register a filter with addFilter:
eleventyConfig.addFilter("uppercase", (str) => {
return String(str).toUpperCase();
});
Use it immediately:
{{ "hello" | uppercase }}
The dev server hot-reloads config changes — no restart needed.
Chaining filters
Filters can be chained, and they pass the result left-to-right:
{{ content | striptags | truncate(160) }}
That strips HTML first, then truncates to 160 characters.
Filters with arguments
Arguments go in parentheses:
{{ posts | head(5) }}
{{ title | truncate(80) }}
{{ docs | where("category", "design") }}
Shortcodes vs. filters
Filters transform a value. Shortcodes render larger blocks of HTML and may take many arguments. For bigger pieces of rendering, use a shortcode (defined with addShortcode) or an include.
What to do next
- Custom layouts for wholesale template changes.
- Add a new section for section-level customization.
- Project structure for where
eleventy.config.jslives.
Browse Support for community channels and paid support options, or book a call if you'd like me to set it up for you.