Evaluating hugo build (runtime) flags in templates


#1

How can I test the value of a hugo build flag from a template?
For example, I want to write a shortcode that behaves differently depending on whether hugo was run with the --buildDrafts (or -D) flag.
(I know how to use $.Page.IsDraft to check whether a given page sets draft to true, but this is not what I’m after here.)


#2

You can not, but you can get environment vars from templates, which may be helpful.


#3

You mean that instead of or in addition to setting the hugo build flag I can set an equivalent environment variable, and then read this variable from my template/shortcode? That could work.
How do I read an environment variable in the template?


#4