Is it possible to have a templating function in a value in config.toml?

For example:

copyright = "Copyright © {{ .Date | time.Format "2006" }} All Rights Reserved."

And then have that function bit render out the current year?

Is there some way to do this or do things need to be reworked for a different approach? (which is fine, I already have one in mind, just wondering if it’s even a thing).

Don’t think so. Config is to set values not proceed with than set.

I just to this in my footer and works fine.

© {{ now.Format "2006"}} {{ or .Site.Title }}

Off course, when the new year comes, this will refresh when the site is built in the new year, but that the static approach, hence no issue.

You can use JavaScript if you always want to serve current year based on user OS settings.

1 Like

I tried that initially when I was moving to Hugo, but the toml file throws errors with anything put in curly brackets. You can try something like this in config.toml.

copyright  = "Copyright © {year} All Rights Reserved."

Then wherever you want the code to appear, you do

{{ replace site.Copyright "{year}" (string (now.Format "2006") ) }}

Ya that’s essentially what I did