`$.Site` context issue with `resource.ExecuteAsTemplate`


{{- $main := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "output.scss" . }}`


{{ $.Site.Title }}


Error: Error building site: EXECUTE-AS-TEMPLATE: failed to transform "scss/main.scss" (text/x-scss): template: scss/m
ain.scss:1:4: executing "scss/main.scss" at <$.Site.Title>: can't evaluate field Site in type string

My assumption was that it should pull the title from config.toml. Am I missing something? Just {{ . }} returns default.

Try the global site function, i.e. site.Title

This did the trick - is this something particular for templating that you use the function site instead?

The site function works irrespective of a template’s context.

The error tells that the “.” above is a string. @onedrawingperday is right about the site workaround, but you should probably look at the original problem and understand it (which is hard for us without additional … context).

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