Closed zxkane closed 2 years ago
Ugh, I don't know how these things happen when I test every PR, run the automated tests, and everything passes...
Unfortunately I'm going to be pretty unavailable this coming week. If anyone else has the capacity to look into this please do. Based on the error message some asset is probably getting run through Hugo Pipes when it shouldn't be; if I had to guess probably something from staticDir, when not using page bundles.
Is the theme wholesale "broken" because of that PR or is this a corner case issue?
Not sure whether it's a corner case only. Tried building with --log -vvv --debug
options, no useful information was given. I guess running into the
issue when rendering the index page.
Kane
On Mon, Apr 25, 2022 at 7:59 PM Chip Zoller @.***> wrote:
Is the theme wholesale "broken" because of that PR or is this a corner case issue?
— Reply to this email directly, view it on GitHub https://github.com/chipzoller/hugo-clarity/issues/288#issuecomment-1108478815, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGN4J74SB2SGIVSBDH67Q3VG2CJFANCNFSM5UHDQQXA . You are receiving this because you authored the thread.Message ID: @.***>
Hope this helps. I am a retired software engineer, but very new to Hugo. I have a website running Hugo with a different theme, but I have been spending time trying to convert my website to the Clarity theme.
Anyway, when I try to run the latest git version of clarity with my test site via "hugo server" I am seeing the same error:
$ hugo server Start building sites … hugo v0.97.3+extended darwin/amd64 BuildDate=unknown Error: Error building site: "/Users/george/Hugo/aporg/themes/hugo-clarity/layouts/_default/_markup/render-image.html:22:21": execute of template failed: template: _default/_markup/render-image.html:22:21: executing "_default/_markup/render-image.html" at <$image.Content>: nil pointer evaluating resource.Resource.Content
But when I follow "Option 1" and run the "Example" site, it works fine. My test environment is using page bundles. I can try to spend some time this week to see if I can isolate what configuration/site option that may be causing the issue. But my knowledge of the code is still somewhat limited.
But it appears that may be this is a "corner case issue" and not a broken theme.
Hope this helps, George
Ok, from a content point of view, I found the offending line that was causing the issue:
george@imac1:~/Hugo/aporg/content/posts $ diff ~/backup/aporg/content/posts/markdown-syntax.md . 53d52 <
That URL does not exist. This is from the original exampleSite that I have been working with for several days. I had previously noticed that the remote image did not exist, but it did not cause any Hugo failures. I now see that the in the most recent example site, the URL has been fixed.
After I fixed (deleted) this line, I found a different failure:
george@imac1:~/Hugo/aporg $ hugo server Start building sites … hugo v0.97.3+extended darwin/amd64 BuildDate=unknown Error: Error building site: execute of template failed: template: _default/_markup/render-image.html:35:4: executing "_default/_markup/render-image.html" at <partial "figure" (dict "file" $file "image" $image "dir" $.Page.File.Dir "alt" $alt "cap" $cap "classes" ($scratch.Get "classes") "bundle" $bundle)>: error calling partial: "/Users/george/Hugo/aporg/themes/hugo-clarity/layouts/partials/figure.html:45:18": execute of template failed: template: partials/figure.html:45:18: executing "partials/figure.html" at <.Width>: error calling Width: *resources.genericResource is not an image Built in 80 ms
And that error was caused by:
george@imac1:~/Hugo/aporg/content/about $ diff ~/backup/aporg/content/about/index.md . 27d26 <
That ko-fi image button was previously working before the latest updates. After deleting this line, I got a clean build.
I hope that this helps to pinpoint what's going on in the code.
Sorry, forgot to use the "add code" block.
george@imac1:~/Hugo/aporg/content/posts $ diff ~/backup/aporg/content/posts/markdown-syntax.md . 53d52 < ![Jane Doe](https://raw.githubusercontent.com/chipzoller/hugo-clarity/master/static/images/jane-doe.png "This is Jane Doe")
Sorry for the extra posts, the other failure was:
george@imac1:~/Hugo/aporg/content/about $ diff ~/backup/aporg/content/about/index.md . 27d26 < [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D67VIRR)
OK, just reading through things -- again sorry I don't have bandwidth this week to dig into a fix. But seems like two issues:
markdown-syntax.md
(and I would guess the .pt
version as well) had a broken image link. Since we removed the error message and told Hugo to just fail a build on a broken image (which is its default behavior), it did as we asked and failed on the old versions of these files. We've updated those files, but people with existing sites who still have those example files hanging around will experience the failure. The fix would be to either delete the example files (if they aren't using them) or re-copy them from exampleSite
. However I'm not sure how to communicate that to folks.imageConfig
, width
, height
, etc).If anyone wants to take a crack at a PR for either or both of these things, please do; if not I'll try to fix it when I return.
In #297 we can now handle SVG images without causing a failed build, so that addresses the second issue. I still don't know how (or if) to notify users of updated exampleSite
files.
After checking out the latest the main branch, I can see the link when rendering the dead thumbnail link. After resolving those dead thumbnail link, still got below error message without any clues.
Error: Error building site: "/home/ubuntu/environment/articles/themes/hugo-clarity/layouts/_default/_markup/render-image.html:21:18": execute of template failed: template: _default/_markup/render-image.html:21:18: executing "_default/_markup/render-image.html" at <$image.MediaType.MainType>: nil pointer evaluating resource.Resource.MediaType
It would be great helpful if the source file name can be logged when specifying the --debug
option.
What's happening is that for whatever reason, the resource that's trying to be loaded as an image isn't being evaluated by Hugo to be an image. So while I don't know what is causing the error, we can update the handling of the resources to ensure it doesn't fail, at least at this stage. (If your browser also doesn't see the referenced file as an image, it'll result in a broken image tag, but presumably that's a lot easier to debug.)
It would be great helpful if the source file name can be logged when specifying the --debug option.
I agree. There are lots of requests for this in Hugo (gohugoio/hugo/issues/6926, gohugoio/hugo/issues/7480, gohugoio/hugo/issues/6964 are some examples). Unfortunately it's not something Hugo provides, at least in this context, and it's out of scope for something a theme can do.
@zxkane If you feel up to testing a branch, take a look at #305 and see if it resolves the issue.
No, the error message still is same. I already turned out the root cause via binary searching of posts. It's caused by the dead image links in the post(md file).
The procedure to find out the post files is really annoying, some hints for image link would be helpful a lot.
did you try upgrading hugo to the latest version? I had something similar a few weeks ago and after upgrading to version 0.98.something (latest), it was solved for me
did you try upgrading hugo to the latest version? I had something similar a few weeks ago and after upgrading to version 0.98.something (latest), it was solved for me
My hugo was 0.98+extended
, the behavior is same after upgrading to v0.99.0+extended
.
Right, as noted above, we changed the code in one of the example posts. There's no way for us to force-push those into anyone's site; they just need to be copied again to get the latest versions. In the past I think this hasn't been high priority to emphasize since we imagine most people will remove the example posts once they launch a site. (Perhaps that is an incorrect assumption.)
As for links to the file causing the image issue, Hugo really doesn't give us many tools to do that; all it will do is point to the template file itself. Multiple people have asked Hugo devs to add that kind of information, as I linked to, but so far they seem to consider providing the template filename sufficient. As theme developers there's not really a lot we can do, unfortunately.
Edited #305 slightly; now it affirmatively will not fail a build on broken image requests (you'll just get a broken image).
I have checked all the prerequisites below and I'm yet experiencing a problem
Describe the bug
After updating theme to latest main branch with #278, building the site with below error,
I'm building the site from this repo, https://github.com/zxkane/articles
Desktop (please complete the following information):