Check if disableHugoGeneratorInject is set

In theme templates, is there any way to determine whether config parameter disableHugoGeneratorInject was set in hugo.toml of the site that makes use of my template?

Something like:

{{ if not site.Config.disableHugoGeneratorInject }}  <-- .disableHugoGeneratorInject does not exist!
{{ hugo.Generator }}
{{ end }}

No, but you don’t need to specifically insert {{ hugo.Generator }} either. If disableHugoGeneratorInject is false or unset, Hugo will insert the meta tag on the home page.

I know that.

In my case a theme deliberately inserts hugo.Generator on all pages, not only on the home page.
Now a user set disableHugoGeneratorInject to true and complains that the theme disregards this setting and unconditionally inserts a generator tag. Of course I can evaluate an additional setting like disableHugoGeneratorInjectAllPages from site.Params, but this is somehow an unwanted duplication. That’s the reason why I asked.

That’s unfortunate.

May I ask why?

And why does hugo.Generator exist then?

Because if you manually insert it in a theme template, theme users cannot disable it using the predefined configuration setting.

Yes, I see. This thread was actually meant as an attempt to find a way to overcome this unfortunate shortcoming, but there seems to be no way right now. What about exposing the disableHugoGeneratorInject setting in a future version of hugo so that it can be used in templates? Certainly not a pressing problem, but nice to have IMHO.

I don’t see that happening.

A simple PR to solve this would suffice, no?

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