Each variable comes from a "context". config.toml file defines the config, frontmatter in _index.md files define section and frontmatter of every other markdown file defines a page context to be used in templates. When you are referring to a variable from a context, you should mention variable name along with the context it comes from separated with DOTs, like context.my_variable
or context.extra.my_extra_variable
if defined after [extra]
.
We are going to declare titles for different contexts, and none of them will overwrite each other.
config.toml
base_url = "https://murtezayesil.me/"
title = "Murteza Y"
config.title
= Murteza Y
content/blog/_index.html
---
title = "Blog"
---
# Blog
Welcome to my corner of the internet.
section.title
= Blog
content/blog/my-first-post.md
---
title = "Blogging in 2025?"
---
Of course.
page.title
= Blogging in 2025?
template/index.html
{% set title = "Home" %}
{{ title }}
= Home
{{ this.title }}
= Home
this is a special context that refers to that file. It can be omitted. Since you didn't specify any context, Tera reasonably assumed that you were omitting this and looked for this.title.
This might be confusing early on. Luckily, Tera provides {{ __tera_context }}
variable which prints out all defined variables in all known contexts. If that is hard to comb through, ShawnPConroy on Zola's Discourse Forum shared this script which organizes them.
In case of the issue you are having, here is a snippet from my theme:
<title>
{% block window_title %}
{% if page.title %}
{{ page.title }} -
{% elif section.title %}
{{ section.title }} -
{% endif %}
{{ config.title }}
{% endblock window_title %}
</title>
This means,
if page.title exists, print {{ page.title }} - {{ config.title }}
else if section.title exists, print {{ section.title }} - {{ config.title }}
otherwise, just {{ config.title }}