---
title: 'Filters'
description: 'Filters baseline registers, grouped by module: when each is available and what it does.'
slug: 'filters'
type: 'article'
date: 2026-04-28T00:00:00.000Z
lang: 'en'
url: 'https://www.eleventy-baseline.dev/docs/core-reference/filters/'
---

Eleventy filters Baseline registers. Some are always available; the rest come on with the module that registers them.

---

## At a glance

| Filter                                                               | Module      | Registered when                  |
| -------------------------------------------------------------------- | ----------- | -------------------------------- |
| `markdownify`, `relatedPosts`, `isString`                            | core        | always                           |
| `inlineESbuild`, `inlinePostCSS`                                     | `assets`    | always (assets is unconditional) |
| `i18nTranslationsFor`, `i18nTranslationIn`, `i18nDefaultTranslation` | `multilang` | when multilingual is active      |
| `_inspect`, `_json`, `_keys`                                         | `navigator` | when navigator is active         |

---

## Core filters

Registered by the entry point on every build.

---

### `markdownify`

Render an inline markdown string to HTML. No wrapping `<p>` tag (uses `markdown-it`'s `renderInline`). Raw HTML in the input passes through untouched.

{% raw %}

```nunjucks
{{ "Read the **manual**." | markdownify }}
```

{% endraw %}

Use it for short bits of markdown that live in front matter or data files (taglines, descriptions). Block-level markdown belongs in `.md` files, not in `markdownify`.

Because it shares the same markdown-it instance as Baseline's amendments, inline-level extensions apply here too: `[[slug]]` wikilinks resolve, and {% raw %}`{#id .class}`{% endraw %} attribute syntax works on inline spans. Block-level features (auto heading IDs) do not fire because `renderInline` skips the block parser.

---

### `relatedPosts`

Filter the current page out of a collection. The page is read from `this.ctx.page` at render time.

{% raw %}

```nunjucks
{% asyncEach item in collections.docs | relatedPosts %}
	{% include "partials/related-card.njk" %}
{% endeach %}
```

{% endraw %}

If the page has no `url` (rare), the filter returns the collection unchanged.

---

### `isString`

A type guard: `true` when the value is a string, `false` otherwise. Useful in templates that accept either a scalar or an object.

{% raw %}

```nunjucks
{% if value | isString %}
	<p>{{ value }}</p>
{% else %}
	<p>{{ value.text }}</p>
{% endif %}
```

{% endraw %}

---

## Assets filters

Registered by the [[assets | assets module]], which is always active.

Both inline filters return raw `<script>` or `<style>` markup as a string. Nunjucks escapes strings by default, so pipe through `| safe` (or use `{% raw %}{{- value | safe -}}{% endraw %}` to also strip surrounding whitespace) when you want the markup to render as HTML rather than as literal angle brackets in the page.

---

### `inlineESbuild`

Async filter. Bundle a JS file through esbuild and return it wrapped in `<script>` tags, ready to drop into a template.

{% raw %}

```nunjucks
{% set jsPath = _baseline.paths.assets ~ "js/critical.js" %}
{{ jsPath | inlineESbuild({ minify: true }) | safe }}
```

{% endraw %}

Accepts the same options as the `assets.esbuild` config; per-call options are merged on top of the module-level defaults. Errors are non-fatal: a `<script>/* Error processing JS */</script>` placeholder is returned instead, and the build continues.

---

### `inlinePostCSS`

Async filter. Process a CSS file through PostCSS (preset-env + cssnano) and return it wrapped in `<style>` tags.

{% raw %}

```nunjucks
{% set cssPath = _baseline.paths.assets ~ "css/critical.css" %}
{{ cssPath | inlinePostCSS | safe }}
```

{% endraw %}

Same error semantics as `inlineESbuild`: failures return a `<style>/* Error processing CSS */</style>` placeholder and the build continues.

---

## Multilang filters

Registered by the [[multilang | multilang module]], available only when multilingual mode is active. All three operate on `collections.translations` and a page's `translationKey`.

---

### `i18nTranslationsFor(page, collection)`

Returns every page in `collection` that shares the current page's `translationKey`. Useful for rendering a language switcher.

{% raw %}

```nunjucks
{% set translations = page | i18nTranslationsFor(collections.translations) %}
{% for variant in translations %}
	<a href="{{ variant.url }}" hreflang="{{ variant.lang }}">{{ variant.lang }}</a>
{% endfor %}
```

{% endraw %}

---

### `i18nTranslationIn(page, collection, lang)`

Returns the page in `collection` matching the current `translationKey` and the requested `lang`, or `null` if no match exists.

{% raw %}

```nunjucks
{% set fr = page | i18nTranslationIn(collections.translations, "fr") %}
{% if fr %}
	<a href="{{ fr.url }}">Lire en français</a>
{% endif %}
```

{% endraw %}

---

### `i18nDefaultTranslation(page, collection)`

Returns the page in `collection` matching the current `translationKey` in the site's `defaultLanguage`, or `null` if none exists. Handy for canonical resolution and fallbacks.

{% raw %}

```nunjucks
{% set canonical = page | i18nDefaultTranslation(collections.translations) %}
```

{% endraw %}

---

## Navigator filters

Registered by the [[navigator | navigator module]] when active (default in development). All three are debugging helpers; treat them as dev-only.

### `_inspect`

Pretty-print a value using Node's `util.inspect`. Defaults: `depth: 4`, `maxArrayLength: 10`, `breakLength: 80`, `compact: true`. Override per-call by passing an options object.

{% raw %}

```nunjucks
<pre>{{ page | _inspect({ depth: null }) }}</pre>
```

{% endraw %}

The navigator template (`/navigator-core.html`) uses `_inspect` with `depth` set from `inspectorDepth` (default `4`; configurable via `options.navigator.inspectorDepth`).

---

### `_json`

Serialise a value with `JSON.stringify`. Second argument is the indentation, default `0` (compact).

{% raw %}

```nunjucks
<pre>{{ page | _json(2) }}</pre>
```

{% endraw %}

---

### `_keys`

Return an object's own keys, sorted alphabetically.

{% raw %}

```nunjucks
{{ page | _keys | join(", ") }}
```

{% endraw %}

---

## See also

- [[plugin-entrypoint | Plugin entrypoint]] - registration order.
- [[assets | Assets module]] - what the inline filters share with the build pipeline.
- [[multilang | Multilang module]] - how `translationKey` and `collections.translations` are populated.
- [[navigator | Navigator module]] - the `_runtime` and `_ctx` Nunjucks globals that pair with these filters.
