congo
congo copied to clipboard
Congo theme error function "hasSuffix" not defined
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
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 -}}
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 ?
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
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.
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
I can't replicate this issue. As suggested above, have you tried upgrading your Hugo version?