Templating
The field value is null, or a MarkdownData object. .raw is what went in, and the other three are what comes out of it, each with its reference tags resolved when the field parses them:
{{ entry.body.raw }} {# the source, exactly as typed #}
{{ entry.body.html }} {# output as HTML #}
{{ entry.body.markdown }} {# output as Markdown, see below #}
{{ entry.body.text }} {# output as plain text #}
{{ entry.body.flavour }} {# the flavour it was parsed with #}
{{ entry.body }} on its own is .raw, not .markdown: the source, tags and all. That’s so Craft’s own filter still works if you’d rather parse it yourself:
{{ entry.body|md('gfm') }}
{{ entry.body|md(inlineOnly=true) }}
Pipe .markdown instead for Craft’s plain parser with the links already resolved: {{ entry.body.markdown|md }}.
Markdown out #
.markdown is for anywhere the output should be Markdown rather than HTML, like an llms.txt. It’s the source as typed, with its reference tags resolved, so [Pricing]({entry:12:url}) comes out as [Pricing](https://example.com/pricing) and nothing else changes:
{# templates/llms.txt.twig #}
# {{ siteName }}
{{ entry.body.markdown|raw }}
Tags inside code are left as typed, the same as in .html. Nothing is purified or encoded, since there’s no HTML yet to do either to. It comes back as a plain string, so Twig escapes it in an HTML template, which is right there. A text file wants |raw, or a & in the Markdown arrives as &. With Parse Reference Tags off, .markdown is the same as .raw.
The |marky filter #
For Markdown that isn’t in a Markdown field, whether a plain text field, a plugin setting, or a string you built in the template, |marky parses it the way the field does: reference tags resolved, HTML purified.
{{ entry.summary|marky }}
{{ entry.summary|marky(flavour='original') }}
{{ entry.summary|marky(refs=false, purify=false) }}
Arguments are flavour, refs, purify, purifierConfig and siteId, all optional.
Craft’s |md is untouched and still the right choice when plain Markdown parsing is all you want. The difference is what each one does beyond parsing:
|md |
|marky |
.html |
|
|---|---|---|---|
| Parses Markdown | ✅ | ✅ | ✅ |
| Resolves reference tags | ❌ | ✅ | ✅ |
| Purifies HTML | ❌ | ✅ | ✅ |
| Uses the field’s settings | ❌ | only when piped a field value | ✅ |
Piping a field value, {{ entry.body|marky }}, is the same as {{ entry.body.html }}, since it takes the field’s own settings. It’s worth doing only to override one of them for a single render:
{{ entry.body|marky(refs=false) }}
Empty fields are null, so the usual guard applies:
{% if entry.body %}
{{ entry.body.html }}
{% endif %}