Skip to content

Template doesn't work with latest version of hugo. #185

@dacjames

Description

@dacjames

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions