I am blocked by a weird issue. I started a new blog post, and when I run hugo server, I get numerous REF_NOT_FOUND errors for pages that I haven’t touched in ages:
hugo server
Watching for changes in /Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/{archetypes,content,data,layouts,static}
Watching for config changes in /Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/config/_default, /Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/go.mod
Start building sites …
hugo v0.131.0+extended darwin/arm64 BuildDate=2024-08-02T09:03:48Z VendorInfo=brew
ERROR [en] REF_NOT_FOUND: Ref "/flow/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/flow2go/index.md:25:24": page not found
ERROR [en] REF_NOT_FOUND: Ref "/bintree": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/big-o/index.md:66:65": page not found
ERROR [en] REF_NOT_FOUND: Ref "/balancedtree/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/big-o/index.md:66:108": page not found
ERROR [en] REF_NOT_FOUND: Ref "/perceptron": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/ai-times-three/index.md:575:86": page not found
ERROR [en] REF_NOT_FOUND: Ref "/balancedtree/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/instantgo/index.md:200:202": page not found
ERROR [en] REF_NOT_FOUND: Ref "/balancedtree": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/generics/index.md:32:168": page not found
ERROR [en] REF_NOT_FOUND: Ref "/generictree": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/generics/index.md:32:233": page not found
ERROR [en] REF_NOT_FOUND: Ref "/release2": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/goman/index.md:104:62": page not found
ERROR [en] REF_NOT_FOUND: Ref "/bintree": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/generictree/index.md:43:19": page not found
ERROR [en] REF_NOT_FOUND: Ref "/balancedtree": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/generictree/index.md:43:94": page not found
ERROR [en] REF_NOT_FOUND: Ref "/awslambda/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/mantil/index.md:24:48": page not found
ERROR [en] REF_NOT_FOUND: Ref "/generictree/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/bintree/index.md:104:183": page not found
ERROR [en] REF_NOT_FOUND: Ref "/release": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/release2/index.md:26:71": page not found
ERROR [en] REF_NOT_FOUND: Ref "/goman/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/release/index.md:45:143": page not found
ERROR [en] REF_NOT_FOUND: Ref "/goman": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/release/index.md:331:9": page not found
ERROR [en] REF_NOT_FOUND: Ref "/generictree/": "/Users/christoph/Documents/Business/AppliedGo/Blog/Hugo/content/post/balancedtree/index.md:181:194": page not found
Built in 2344 ms
Error: error building site: logged 16 error(s)
An example of a failing reference:
In [this article]({{< ref "/bintree" >}}), ...
The tree of the bintree article:
content/post/bintree
├── index.md
└── media
├── <resources...>
I have permalinks settings in action. The relevant line from permalinks.toml:
post = "/:filename/"
So the article in content/post/bintree is available at https://<baseurl>/bintree.
So far, {{< ref "/bintree" >}} perfectly resolved to the correct URL, but now I get these errors. I searched this forum and the Web, but none of the issues around REF_NOT_FOUND seem to match this issue.
Why does Hugo error out on page references that worked earlier?
I use Hugo via Homebrew, and Homebrew cannot install old versions. So I built a few Hugo versions from source:
v0.130.0: no change
v0.129.0: no change
v0.120.0: The number of errors halved, complaining only about references that contain a trailing slash
v0.110.0: Got a whole new range of errors: render of "page" failed: ... execute of template failed: ... can't evaluate field JoinPath in type interace {}. I guess I am using some newer functionality for my site
v0.115.0: same as v0.120.0
v0.112.0: more errors than with 0.115/0.120, but all 14 of them complain about references with a trailing slash, whereas in 0.131.0, only 7 of the references have a trailing slash
If the baseURL was misconfigured, I’d guess that there’d be more errors than just these cross reference errors.
I looked through the Git history of my site, to see if any possibly harmful change jumps into my face, but honestly, I have no idea what to look out for.
Worth noting that the pages that Hugo claims to be unable to find are getting created. The bintree page, for example, exists in /public/bintree after running Hugo, despite the build errors.
Tip: When you do things like installing multiple versions for testing, don’t install the .0 versions; use the latest in those minor versions. Many errors are solved between, e.g. v0.111.0 and v0.111.3. You might save time.
Do you know which version was used the last time. It should work with that one. And it maybe help our gurus to directly see the error
It’s maybe in the meta tags of your life site.
Without code it will be hard to track that down for us. If you could provide a repo I guess we could assist better.
For testing different versions i would also use binary tests. Taken the one in the middle beween working and failing. And go with @davidsneighbour in taking last minor
Thank you for the tip, @davidsneighbour. In my case, the latest version is the one that errors out, so any earlier version, whatever patchlevel, should be fine for bisecting my way towards the last good version.
At one point, the Hugo version was too old to render my current site properly. Between that and the current version, none of the versions I tested compiles my site with no error.
Unfortunately, no. The oldest version I tested is too old to compile my site. I don’t expect that I find a working version between that version and the current one.
I tried to do bisecting (the list of versions I tried is in chronological order of testing), but without any working version, I cannot bisect towards the last working version.
Maybe the reason for the errors lies indeed in some change in my site—a change too subtle to look like it would cross-references.
The trailing slash on the given path is irrelevant.
The baseURL setting is also irrelevant. And to clarify, since v0.123.0 Hugo automatically adds a trailing slash to the baseURL if it does not already exist.
Although the changes are announced in the release notes, this particular bug fix was not called out as a breaking change. I’m sorry we broke your site.