Dynamically create title using externally defined version number

I’m currently working on migrating one of our open source websites that’s using Jekyll to Hugo. We use a site variable to define what is the currently stable version (e.g. 1.16.0). That value needs to be displayed in the title of the page, which is defined as a page variable.

So in our config.toml we have:

[params]
# Version numbers used in the text for stable and snapshot versions,
# e.g. "Documentation for {{ site.stable }".
stable = "1.16"

And in one of the pages that we have, I’m trying to use that defined variable. I’ve tried both defining it first in as shortcode

{{ $.Site.Params.stable }}

And then refer to that shortcode in the page variable, like:

---
title: Flink {{< flink-stable-version >}} (Latest stable release)
icon: <i class="fa fa-cogs title maindish" aria-hidden="true"></i>
bold: true
---

Unfortunately this doesn’t generate the result. It appears that this is not possible with Hugo (also looking at the other support tickets, like Use Front Matter Variable in Page?).

What would be the best way to resolve this need?

You can insert variables into front matter when creating a new content page (via archetypes), but once created the front matter values are immutable.

You will have to handle this at the template level.

@jmooring Thank you for the advice, I’ll resolve this at the template level

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.