fix: show content file path in render error messages#14692
fix: show content file path in render error messages#14692xingzihai wants to merge 1 commit intogohugoio:masterfrom
Conversation
Previously, error messages during template rendering only showed the page kind (e.g., 'render of "page" failed'), making it difficult to identify which content file caused the error when there are many pages. This change uses getPageInfoForError() which provides detailed context: - kind: the page kind - path: the page path - file: the content file path Example error message before: render of "page" failed: ... Example error message after: render of "kind: "page", path: "posts/my-post", file: "/content/posts/my-post.md"" failed: ... Fixes gohugoio#14607
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
|
Summary
Improves error messages when template rendering fails by showing the content file path, making it easier for users to locate the problematic file.
Problem
Previously, when a template render failed, the error message only showed:
This made it difficult for users to identify which content file caused the error.
Solution
Modified
renderForTemplate()insite.goto usegetPageInfoForError()which provides detailed page information:kind: Page type (e.g., "page", "home", "section")path: Page path (e.g., "posts/my-post")file: Content file path (e.g., "/content/posts/my-post.md")New error message format:
Changes
hugolib/site.go- ModifiedrenderForTemplateto usegetPageInfoForError()for better error contextTesting
go build ./...✓go test -v -run TestRender ./hugolib/...✓Fixes #14607