adityatelange / hugo-PaperMod

A fast, clean, responsive Hugo theme.
https://adityatelange.github.io/hugo-PaperMod/
MIT License
9.21k stars 2.51k forks source link

Image render hook vs the new embedded image render hook in 0.123 #1504

Open baekgaard opened 2 months ago

baekgaard commented 2 months ago

PaperMod provides a layouts/_default/_markup/render-image.html render hook.

However, in newer versions of Hugo (0.123 and beyond) a new embedded image render hook is also provided. I think this may be meant as a better way to manage resources in a multilingual setup, but I also found it useful to avoid canonifyURL in cases where the entire site/baseURL is not at the root (i.e. like in www.xxx.yyy/zzz).

The embedded image render hook needs to be manually enabled for some sites, but is automatically enabled for multilingual single-host sites in the default configuration.

It may not be obvious (when debugging) why the embedded image render hook is not accessible when the embedded link render hook works with PaperMod -- at least it took me some minutes to figure out why not all url's were rewritten correctly.

I'm wondering to which degree the render-image.html hook in PaperMod is needed, or if it could be made to work with the embedded image render hook when enabled somehow -- although I don't currently see a good solution for that? I guess it's mainly there to provide the alt text?

In my own site, I simply made the embedded image render hook explicit by replacing (and updating) the render-image.html file with the code of the embedded one.

jmooring commented 2 months ago

With the existing image render hook... https://github.com/adityatelange/hugo-PaperMod/blob/3f50861a0ced88f9b614a43662edeb4c0bc45da8/layouts/_default/_markup/render-image.html

...page resources for non-default languages on a multilingual single-host site will not be found.

The only thing that the existing image render hook does is to add a lazy loading attribute. Either model the hook after Hugo's embedded hook, or remove it.

adityatelange commented 2 months ago

can do

adityatelange commented 1 month ago

...page resources for non-default languages on a multilingual single-host site will not be found.

@jmooring I see we'll face compatibility issues when using hugo < 0.125.0 as PageInner was introduced in 0.125.0

jmooring commented 1 month ago

Your choices:

  1. Require v0.125.0.
  2. Use Page instead of PageInner in the render hook.
  3. Do not include a render hook in your theme. The embedded hooks are automatically enabled for multilingual single-host sites.