chipzoller / hugo-clarity

A theme for Hugo based on VMware Clarity
Other
577 stars 262 forks source link

[Bug] Path to thumbnail images incorrect on second and higher page #427

Open Cyb3r-Jak3 opened 1 year ago

Cyb3r-Jak3 commented 1 year ago

I confirm:

Hugo version

hugo v0.109.0-47b12b83e636224e5e601813ff3e6790c191e371+extended windows/amd64 BuildDate=2022-12-23T10:38:11Z VendorInfo=gohugoio

Where is this bug showing up?

In the browser: Hugo builds the site, but something doesn't look right.

Operating system

Windows 10

Browser (if applicable)

No response

Current behavior

When you have posts that go on to a second page, then the thumbnails images all 404.

An example URL is http://localhost:1313/page/2/images/<folder>/image.png whereas on the first page the thumbnail images are linked to http://localhost:1313/images/<folder>/image.png

Expected behavior

All images that are loaded from the second page and higher still use the page of /images rather than /<page number>/images

Steps to reproduce

Create a project that has at least two pages of posts with thumbnails and go to the second page and there are no thumbnails.

Relevant log output

No response

Related code

My guess is that is comes from this partial https://github.com/chipzoller/hugo-clarity/blob/master/layouts/partials/figure.html

    {{/* Render image and attributes. */}}
    <img
      loading="lazy"
      decoding="async"
      alt="{{ htmlEscape $alt }}"
      {{ with $image }}
        class="{{ $classes }} image_processed"
        width="{{ .Width }}"
        height="{{ .Height }}"
        src="{{ .RelPermalink }}"
      {{ else }}
        class="{{ $classes }} image_unprocessed"
        src="{{ $fileWeb }}"
      {{ end }}
      {{ with $cap }}
        title="{{ safeHTML $cap }}"
      {{ end }}
    />

Preferred solution

Maybe have the images link be src from absolute?

Other information

Similar to https://github.com/chipzoller/hugo-clarity/issues/337

albersonmiranda commented 2 months ago

Also happens with internationalization. When changing from default to second language, all thumbs are 404. Tested fix in #464 , it does works for multi language too.