perplex icon indicating copy to clipboard operation
perplex copied to clipboard

Template doesn't work with latest version of hugo.

Open dacjames opened this issue 9 months ago • 0 comments

The template no longer works with the latest version of hugo, due to two breaking changes:

  • Removal of .Err on resources in favor of try based error handling.
  • Removal of site.IsServer in favor of hugo.IsServer.

I was able to get it working fairly easily by making changes here and to hugo-mod-image and hugo-mod-resource. I can submit PR's if you want but I made some changes along the way like changing module names, getting rid of _vendor, and making unnecessary version tags that you probably don't want.

The actual fix is pretty simple. Convert GetRemote calls like this:

 {{- with resources.GetRemote $url.String }}
    {{- with .Err }}
        {{- $msg := print $errorMsg ". " . }}
        {{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
    {{- else }}
        {{- $r = . }}
    {{ end }}
{{- else }}

To something like this:

 {{- with try (resources.GetRemote $url.String) }}
    {{- with .Err }}
        {{- $msg := print $errorMsg ". " . }}
        {{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
    {{- else with .Value }}
        {{- $r = . }}
    {{- else }}
        {{ errorf "Unable to get remote resource %q" $url }}
    {{ end }}
{{- else }}

Thanks for sharing your work! I hope this helps.

dacjames avatar Apr 27 '25 03:04 dacjames