Can I get the Goldmark config value?

Hi,
Can I get the site config value? (the value in the config.toml file)
I want to use the Goldmark config value(startLevel and endLevel) to make a TOC component look dynamic.

I expect to use it something like this

{{ .Site.Goldmark }}
{{ .Goldmark }}
{{ .TableOfContents  }}
{{ .Site.Config }}

No you cannot.

Ok, Thanks for the reply,
Maybe you have some reasons that I don’t know.
I’ll find another way for the toc

I can give you the short version:

  • If we expose something to the templates, it is hard/impossible to change/remove later
  • This is esp. true for configuration. We often refactor/rename configuration, one example being when we added Goldmark and moved a lot of the top level config elements down below markup. We can easily map from old to new behind the scenes, but if people started using .Site.Config.footnoteAnchorPrefix etc. in their templates (this was moved in 0.61), it would impossible to handle.
  • One other example. We have .Site.BaseURL, which is more or less the value from the config. We have kept it for legacy reasons, but it was probably a mistake to add there, as it lead to lots of manually and error prone URL construction (esp. in themes; does the baseURL end with a slash or not?
  • All of this may take away some flexibility, but it is probably better to let Hugo handle URL creation (via .RelPermalink, relURL etc.) – we may make mistakes, but at least then it’s one place to apply the fix and not a million templates in the wild.
4 Likes