{{ if }} branches end up in different context

What is wrong with that ?

{{ range site.Home.Section.RegularPages }}
<li>
<a href=“{{ .RelPermalink }}” {{ if eq $.Page . }}aria-current=page{{end}}>
{{- partial “docs/title-menu” . -}}
</li>
{{ end }}

to get

Error: error building site: render: failed to render pages: render of “page” failed: execute of template failed: html/template:_default/single.html:61:37: {{if}} branches end in different contexts: {stateAttr delimSpaceOrTagEnd urlPartNone jsCtxRegexp attrNone elementNone }, {stateTag delimNone urlPartNone jsCtxRegexp attrNone elementNone }

That kind of error message is perhaps the most obscure that I get to deal with. The <a line is in fault. This is part of making a menu of all top section pages (so right below content). It’s supposed to work the same for all pages since it calls on .Home to home in on the top section level pages.

Did you try including the attribute in quotes?

You tell me ! I don’t see quotes around aria-current=page.

Nor do I. That’s why I asked if you tried a more traditional approach, namely quoting the attribute value.

Ah, I didn’t get your question… When I try, the message changes.

{{ range site.Home.Section.RegularPages }}
	<li>
	<a href="{{ .RelPermalink }}" {{ if eq $.Page . }}aria-current="page"{{end}}>
	{{- partial "docs/title-menu" . -}}</a>
	</li>
{{ end }}

ERROR render of “home” failed: “/home/drm/Psychototal_hugo/layouts/_default/baseof.html:59:9”: execute of template failed: template: _default/home.html:59:9: executing “_default/home.html” at : can’t evaluate field Pages in type string
ERROR render of “section” failed: “/home/drm/Psychototal_hugo/layouts/_default/baseof.html:59:9”: execute of template failed: template: _default/list.html:59:9: executing “_default/list.html” at : can’t evaluate field Pages in type string
Built in 6 ms
Error: error building site: render: failed to render pages: render of “page” failed: “/home/drm/Psychototal_hugo/layouts/_default/baseof.html:59:9”: execute of template failed: template: _default/single.html:59:9: executing “_default/single.html” at : can’t evaluate field Pages in type string

Probably another line since there’s no reference to Pages in what you posted.

The line is precisely

{{ range site.Home.Section.RegularPages }}

Check out the docs. Section is not what you think it is. And the error message tells you exactly that.

Oh yes,

Returns the name

I ended up importing my old config I am familiar with, and used site.GetPage "docs". As the saying goes, if ain’t broke don’t fix it.