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

Lookup render hook templates by output format, falling back to HTML if present #13242

Closed
nibe opened this issue Jan 10, 2025 · 1 comment · Fixed by #13263
Closed

Lookup render hook templates by output format, falling back to HTML if present #13242

nibe opened this issue Jan 10, 2025 · 1 comment · Fixed by #13263

Comments

@nibe
Copy link

nibe commented Jan 10, 2025

When you add the blockquote render hook "render-blockquote.rss" and don't provide "render-blockquote.html", HTML rendering changes: "render-blockquote.rss" replaces the default HTML blockquote rendering. I assumed it would only affect RSS and it messed up my site. IMO this is counterintuitive.

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.140.2+extended+withdeploy darwin/arm64 BuildDate=2024-12-30T15:01:53Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes.

@jmooring
Copy link
Member

jmooring commented Jan 10, 2025

I've encountered this before, and had to create one for HTML and one for the other output format. This is true for all render hooks, and I understand why.

Today, if you have three output formats and you want to modify the rendering of links (for example) for all output formats in the same way, you only need to create one render hook instead of creating three identical render hooks.

Maybe we should treat HTML as Hugo's default output format1. If there's not a hook targeting the current output format, use the HTML hook if present, else no hook at all. This would be a breaking change, but it wouldn't affect many (any?) users.

In the above, the "HTML hook if present" bit is also true when we're using default render hooks.

Or we could fall back to something like render-link.default.irrelevant. But this would be a much larger breaking change.

Footnotes

  1. This is a bit arbitrary but, from a practical standpoint, true. I guess we determine the "default" output format based on output format weight (i.e., the one with weight=0 is the default) but very few sites give weights to their output formats.

@jmooring jmooring changed the title render-blockquote.rss affects HTML rendering Lookup render hook templates by output format, falling back to HTML if present Jan 10, 2025
@bep bep self-assigned this Jan 15, 2025
@bep bep removed the NeedsTriage label Jan 15, 2025
@bep bep added this to the v0.141.0 milestone Jan 15, 2025
@bep bep added Enhancement and removed Proposal labels Jan 15, 2025
bep added a commit to bep/hugo that referenced this issue Jan 15, 2025
bep added a commit to bep/hugo that referenced this issue Jan 15, 2025
bep added a commit to bep/hugo that referenced this issue Jan 15, 2025
@bep bep closed this as completed in 7699336 Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants