Render of "page" failed: execute of template failed

About this post:

Locally, my version of the site starts up fine, everything works.
But on the server, when building the site, an error occurs:

ERROR 2023/05/17 20:21:40 render of “page” failed: execute of template failed: template: _default/documentation.html:25:9: executing “_default/documentation.html” at <partial “aside.html” (dict “page” . “pages” $pages)>: error calling partial: “/var/www/gc_website/layouts/partials/aside.html:28:24”: execute of template failed: template: partials/aside.html:10:18: executing “partials/aside.html” at <partial “section-menu/walk.html” .>: error calling partial: execute of template failed: template: partials/aside.html:37:14: executing “partials/section-menu/walk.html” at <partial “section-menu/walk.html” (dict “page” $.page “pages” .)>: error calling partial: execute of template failed: template: partials/aside.html:37:14: executing “partials/section-menu/walk.html” at <partial “section-menu/walk.html” (dict “page” $.page “pages” .)>: error calling partial: execute of template failed: template: partials/aside.html:28:24: executing “partials/section-menu/walk.html” at <$.page.Ancestors>: can’t evaluate field Ancestors in type interface {}

aside.html:

<button class="aside-button" type="button" id="aside-button" aria-haspopup="true" aria-expanded="false" aria-label="Open sidebar">
</button>
<div class="aside-wrapper" >
  <div class="aside">
    <div class="aside__inner" id="aside-inner">
      <aside>
        <h2>Navigation</h2>
          <nav class="menu-section">
            <ul>
              {{- partial "section-menu/walk.html" . }}
            </ul>
          </nav>
      </aside>
    </div>
  </div>
</div>

{{- define "partials/section-menu/walk.html" }}
  {{- range .pages }}
    {{- if not .Params.exclude }}
    <li>
      {{- if .Params.sectionMenuTextOnly }}
        <h3>{{ .LinkTitle }}</h3>
      {{- else }}
        {{- if .Eq $.page }}
          <a class="active" aria-current="page" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
        {{- else if in $.page.Ancestors . }}
          <a class="ancestor" aria-current="true" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
        {{- else }}
          <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
        {{- end }}
      {{- end }}
      {{- with .Pages }}
        <button type="button" class="aside-list__toggle"></button>
        <ul class="aside-list">
          {{- partial "section-menu/walk.html" (dict "page" $.page "pages" .) }}
        </ul>
      {{- end }}
    </li>
    {{- end }}
  {{- end }}
{{- end }}

What could be different locally on my computer and on the server and create this error? I have to add something to config file, or the reason in different versions of hugo?

1 Like

I suspect your “server” is building with an older version of Hugo.

1 Like

Is it possible to specify a required version of hugo in the config file?

How are you serving your site? Netlify? GitHub Pages? Other?

From what I understand, I guess you want to specify the version of Hugo in config.toml or hugo.toml file. Then you expect your server to use that specific version of Hugo while deploying your website. Unfortunately this is not possible as of now.

However, there are service-specific instructions available (for services like Netlify, Cloudflare Pages, AWS Amplifiy, etc.) that tell their server to deploy your website using a particular version of Hugo. You can find guides relating to this here: Hosting and deployment | Hugo .

Rightly said @jmooring . This could be the issue since .Ancestors was released in Release v0.109.0 · gohugoio/hugo · GitHub . So if you use any version of Hugo less than v0.109.0, you should not expect your template/website to work.

1 Like

Other

You can place this in your config file:

[module]
  [module.hugoVersion]
    extended = true
    min = '0.111.0'

This will throw a warning, but not an error (i.e., it won’t fail the build).

WARN 2023/05/19 16:45:05 Module “project” is not compatible with this Hugo version

But the version comparison ignores the patch portion of the semantic version string. For example, it treats 0.111.3 the same as 0.111.0.

1 Like

Thank you for such a detailed answer.

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