Skip to content

fix: show content file path in render error messages#14692

Open
xingzihai wants to merge 1 commit intogohugoio:masterfrom
xingzihai:fix-error-show-content-file
Open

fix: show content file path in render error messages#14692
xingzihai wants to merge 1 commit intogohugoio:masterfrom
xingzihai:fix-error-show-content-file

Conversation

@xingzihai
Copy link
Copy Markdown
Contributor

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:

render of "page" failed: execute of template failed...

This made it difficult for users to identify which content file caused the error.

Solution

Modified renderForTemplate() in site.go to use getPageInfoForError() 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:

render of "kind: "page", path: "posts/my-post", file: "/content/posts/my-post.md"" failed: execute of template failed...

Changes

  • hugolib/site.go - Modified renderForTemplate to use getPageInfoForError() for better error context

Testing

  • go build ./...
  • go test -v -run TestRender ./hugolib/...

Fixes #14607

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
@gemini-code-assist
Copy link
Copy Markdown

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error 'render of "page" failed' does not mention content file

2 participants