gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.64k stars 7.52k forks source link

Different lookup order for shortcode templates #12792

Open jmooring opened 2 months ago

jmooring commented 2 months ago

While updating the related documentation, I thoroughly tested the lookup order for shortcode templates and was surprised by the results. The updated documentation matches the behavior of v0.133.0:

https://gohugo.io/templates/shortcode/#template-lookup-order

This obviously isn't a big problem or we would have heard about it before now.

Testing notes:

git clone --single-branch -b hugo-github-issue-12792 https://github.com/jmooring/hugo-testing hugo-github-issue-12792
cd hugo-github-issue-12792
hugo server
hugo && cat public/en/index.html

Then start removing the shortcode templates one by one, going from most specific to least specific according to: https://gohugo.io/templates/shortcode/#template-lookup-order

bep commented 2 months ago

and was surprised by the results.

Can you be more ... specific?

jmooring commented 2 months ago

This doesn't look right to me: https://gohugo.io/templates/shortcode/#template-lookup-order

But it matches current behavior.

bep commented 2 months ago

This doesn't look right to me

That wasn't what I meant about ... more specific. OK, I assume you then also mean that it's different from other templates (e.g. render hooks).

Shortcodes has its own lookup function for technical reasons that's no longer (as) valid. We could/should rewrite this to use the same logic used elsewhere.