Skip to content

Bug: getJSON not defined — incompatibility with Hugo ≥ v0.156.0 #765

@Ricardo-Simoes

Description

@Ricardo-Simoes

Following the official installation instructions at https://theme-cards.hbstack.dev/docs/install-from-scratch/, the last step (npm run dev) fails with the following error when using Hugo ≥ v0.156.0:

huge: downloading modules …
hugo: collected modules in 87854 ms
ERROR "/home/myuser/.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugomods/giscus@v0.1.1/layouts/partials/giscus/repo-id.html:1:1": parse of template failed: template: _partials/giscus/repo-id.html:1: function "getJSON" not defined

Root cause

The getJSON template function was deprecated in Hugo v0.123.0 and permanently removed in Hugo v0.156.0 (see Hugo v0.156.0 release notes). The dependency github.com/hugomods/giscus@v0.1.1 still uses getJSON in layouts/partials/giscus/repo-id.html, which causes a hard parse error on Hugo ≥ v0.156.0.

Environment

  • Hugo version: 0.157.0
  • OS: Arch Linux
  • Affected dependency: github.com/hugomods/giscus@v0.1.1
  • Last known working Hugo version: 0.155.3

Steps to reproduce

  1. Follow the instructions at https://theme-cards.hbstack.dev/docs/install-from-scratch/
  2. Run npm run dev (which runs hugo server --gc -D)
  3. Observe the error above

Expected behavior

hugo server starts without errors.

Suggested fix

The getJSON call in github.com/hugomods/giscus should be replaced with resources.GetRemote combined with transform.Unmarshal, as recommended by Hugo's migration guide. This may require updating the dependency on hugomods/giscus to a version that has already applied this fix, or patching it directly.

Reference: https://gohugo.io/functions/resources/getremote/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions