# \_index front matter and Tera's ternary operator and optional chaining

**URL:** <https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950>\
**Category:** Support\
**Created:** [July 18, 2026, 9:16pm UTC](https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950 "2026-07-18T21:16:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![videbar](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@videbar](https://zola.discourse.group/u/videbar)\
**Post date:** [July 18, 2026, 9:16pm UTC](https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950/1 "2026-07-18T21:16:21Z")

</div>

Hi everyone, I’m trying to build a Tera template such that it attempts to read some `[extra]` fields from `_index.md` and use some default values if those fields don’t exist. I’ve tried to do this using [Tera’s optional chaining](https://keats.github.io/tera/#optional-chaining) and [the ternary operator](https://keats.github.io/tera/#ternary), but I couldn’t manage to make it work. Here’s a basic example of what I’m trying to achieve. After running `zola init` I create the following files:

- `content/test.md`, which contains:

- `templates/base.html`, which contains:

What I want to do is try to read `var_2` from the front matter of `test.md` and, if it’s undefined, use a default value. When I try to achieve this using either optional chaining or the ternary operator I get similar errors:

```auto
* Failed to parse "zola_test/templates/base.html"
  --> 28:32
   |
28 | {% set var_2 = page.extra.var_2? or "default" %}
   | ^---
   |
   = expected `or`, `and`, `not`, `<=`, `>=`, `<`, `>`, `==`, `!=`, `+`, `-`, `*`, `/`, `%`, a filter, or `%}` or `-%}`

```

```auto
* Failed to parse "/home/videbar/repos/zola_test/templates/base.html"
  --> 39:33
   |
39 | {% set var_2 = page.extra.var_2 if page.extra.var_2 else "default" %}
   | ^---
   |
   = expected `or`, `and`, `not`, `<=`, `>=`, `<`, `>`, `==`, `!=`, `+`, `-`, `*`, `/`, `%`, a filter, or `%}` or `-%}`

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [July 19, 2026, 7:20am UTC](https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950/2 "2026-07-19T07:20:20Z")

</div>

This will work in the next version of Zola. I need to update the current docs to say that the current version of Zola (\<= 0.23) uses tera v1.

---

<div class="post-metadata">

**Author:** ![Colas.Nahaboo](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/colas.nahaboo/32/1610_2.png) [@Colas.Nahaboo](https://zola.discourse.group/u/Colas.Nahaboo)\
**Post date:** [July 19, 2026, 8:06am UTC](https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950/3 "2026-07-19T08:06:32Z")

</div>

In Tera v1, this works:

```auto
{% set var_2 = page.extra.var_2 | default(value="default") %}

```

---

<div class="post-metadata">

**Author:** ![videbar](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@videbar](https://zola.discourse.group/u/videbar)\
**Post date:** [July 19, 2026, 12:07pm UTC](https://zola.discourse.group/t/index-front-matter-and-teras-ternary-operator-and-optional-chaining/2950/4 "2026-07-19T12:07:25Z")

</div>

Cool, thanks a lot for the effort you put into it, I see that there’s already a remark in Zola’s documentation.
