congo icon indicating copy to clipboard operation
congo copied to clipboard

Congo theme error function "hasSuffix" not defined

Open memcpy101 opened this issue 11 months ago • 5 comments

Language

English

What's the issue?

Trying to start hugo with the theme congo fresh from a install and I get the error below. Any idea how to fix ?

hugo server go: no module dependencies to download hugo: downloading modules … go: downloading github.com/jpanther/congo/v2 v2.8.0 go: downloading github.com/jpanther/congo v1.6.4 go: added github.com/jpanther/congo/v2 v2.8.0 hugo: collected modules in 7839 ms Error: add site dependencies: load resources: loading templates: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/_markup/render-link.html:11:1": parse failed: template: _default/_markup/render-link.html:11: function "hasSuffix" not defined

Theme version

v2

Hugo version

v0.92.2+extended

Relevant Hugo log output

hugo server
go: no module dependencies to download
hugo: downloading modules …
go: downloading github.com/jpanther/congo/v2 v2.8.0
go: downloading github.com/jpanther/congo v1.6.4
go: added github.com/jpanther/congo/v2 v2.8.0
hugo: collected modules in 7839 ms
Error: add site dependencies: load resources: loading templates: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/_markup/render-link.html:11:1": parse failed: template: _default/_markup/render-link.html:11: function "hasSuffix" not defined

memcpy101 avatar Mar 01 '24 01:03 memcpy101

The template tries to load and get an error

cat "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/_markup/render-link.html" {{- $link := .Destination -}} {{- $isRemote := strings.HasPrefix $link "http" -}} {{- if not $isRemote }} {{ $url := urls.Parse .Destination }} {{- if $url.Path }} {{ $fragment := "" }} {{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}} {{- with .Page.GetPage $url.Path }} {{ $link = printf "%s%s" .RelPermalink $fragment }} {{ else }} {{- if hasSuffix $url.Path ".md" }} {{ warnf "[CONGO] Can't resolve: %s" .Destination }} {{ end -}} {{ end -}} {{ end -}} {{ end -}}

<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}

memcpy101 avatar Mar 01 '24 01:03 memcpy101

I found that many files the functions are missing the . in the beginning like .page or .continue etc.. Is that because of the version of Hugo or the files need to be corrected ?

memcpy101 avatar Mar 01 '24 02:03 memcpy101

After fixing the files, now I am getting the following errors hugo server Start building sites … hugo v0.92.2+extended linux/amd64 BuildDate=2023-01-31T11:11:57Z VendorInfo=ubuntu:0.92.2-1ubuntu0.1 ERROR 2024/02/29 21:16:41 render of "taxonomy" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:5:12": execute of template failed: template: _default/taxonomy.html:5:12: executing "_default/taxonomy.html" at : can't evaluate field LanguageCode in type *langs.Language ERROR 2024/02/29 21:16:41 render of "taxonomy" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:5:12": execute of template failed: template: _default/taxonomy.html:5:12: executing "_default/taxonomy.html" at : can't evaluate field LanguageCode in type *langs.Language Error: Error building site: failed to render pages: render of "home" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:5:12": execute of template failed: template: index.html:5:12: executing "index.html" at : can't evaluate field LanguageCode in type *langs.Language Built in 35 ms

memcpy101 avatar Mar 01 '24 02:03 memcpy101

I was able to fix by adding 2.6.1 version in the go.mod file, seems that any version >=2.7.0 doesn't work.

memcpy101 avatar Mar 01 '24 02:03 memcpy101

you’re running a pretty old version of hugo…

the latest is 0.123.7 as of yesterday… there’s a lot of changes; most of them good… but if you’re just starting out you’ll really be best served by starting there

wolfspyre avatar Mar 02 '24 01:03 wolfspyre

I can't replicate this issue. As suggested above, have you tried upgrading your Hugo version?

jpanther avatar Mar 09 '24 03:03 jpanther