[SOLVED] How to call site variables inside of other "scopes"

I am not sure if “scope” is the right term.

I have the following code:

{{ with .Params.images }}{{ range first 6 . }}
	<meta property="og:image" content="{{ .Site.BaseURL }}{{ . }}" />
{{ end }}{{ end }}

The {{ .Site.BaseURL }} does not work (“can’t evaluate field Site”) because we are inside of .Params.images… What would be the right way to refer in this situation to a “root” variable?

Have you tried {{ . | absURL }}?

1 Like

That created the url in this specific case.

I can’t think of any other use case where I would need access to a root variable inside of a special scope… so this answer solved my issue :slight_smile:

For with and range
You can use {{ $.Site.BaseURL }}

The top level page context is stored in $

1 Like

That was the initial question. Probably very useful later on :slight_smile: