Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .Page.SourceInfo #12998

Open
bep opened this issue Nov 1, 2024 · 4 comments
Open

Add .Page.SourceInfo #12998

bep opened this issue Nov 1, 2024 · 4 comments
Labels
Milestone

Comments

@bep
Copy link
Member

bep commented Nov 1, 2024

In many template error/warning situations (when we don't have any .Pos info), a common need is to have some way of referring to the source, e.g. where to fix the issue, e.g.

{{ warnf "you need to fix the front matter in %s" .Path }}

The problem with the above is that .Path in many cases is not very precise and not something I can just click on and take you to the source.

It would be practical if I would just do:

{{ warnf "you need to fix the front matter in %s" .SourceInfo }}

And the struct printed itself with enough information to take me to the correct content file/adapter.

It's certainly possible to create such reference using ifs and withs, but it's much harder than it should be.

@bep bep added the Proposal label Nov 1, 2024
@bep bep added this to the v0.138.0 milestone Nov 1, 2024
@bep
Copy link
Member Author

bep commented Nov 2, 2024

While the above may be a great idea, I think I'm going to start by making the .Page.String method more useful.

bep added a commit to bep/hugo that referenced this issue Nov 2, 2024
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output:

1. Inclusion when `.RenderShortcodes` is wrapped in HTML.
2. Inclusion of Markdown file without a trailing newline in some cases.

Closes gohugoio#12854
Updates gohugoio#12998
bep added a commit to bep/hugo that referenced this issue Nov 3, 2024
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output:

1. Inclusion when `.RenderShortcodes` is wrapped in HTML.
2. Inclusion of Markdown file without a trailing newline in some cases.

Closes gohugoio#12854
Updates gohugoio#12998
bep added a commit to bep/hugo that referenced this issue Nov 3, 2024
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output:

1. Inclusion when `.RenderShortcodes` is wrapped in HTML.
2. Inclusion of Markdown file without a trailing newline in some cases.

Closes gohugoio#12854
Updates gohugoio#12998
bep added a commit that referenced this issue Nov 3, 2024
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output:

1. Inclusion when `.RenderShortcodes` is wrapped in HTML.
2. Inclusion of Markdown file without a trailing newline in some cases.

Closes #12854
Updates #12998
@bep bep modified the milestones: v0.138.0, v0.139.0 Nov 6, 2024
@bep bep modified the milestones: v0.139.0, v0.140.0 Nov 21, 2024
@bep bep modified the milestones: v0.140.0, Unscheduled Dec 11, 2024
@jmooring
Copy link
Member

making the .Page.String method more useful.

This was implemented in v0.137.0.
https://gohugo.io/methods/page/string/

@willfaught
Copy link

I get a 404 for that link.

@jmooring
Copy link
Member

I get a 404 for that link.

We reverted the documentation change. The Page.String method is for internal use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants