hugo-scroll icon indicating copy to clipboard operation
hugo-scroll copied to clipboard

Image sliders on main page not working anymore?

Open ottlinger opened this issue 1 year ago • 19 comments

I recently upgraded to the latest version of hugo-scroll and my image slider on the index page stopped working.

Has that feature been removed? How can I configure multiple images on my start page.

The slider integration was based on a slide.json under the data directory. At the moment no cover image/image at all is shown on the base index page.

ottlinger avatar Jul 20 '24 09:07 ottlinger

The video background on the main page seems to be broken, too: Trying to enable it by providing a custom partial stops rendering with

executing "partials/custom_header_video.html" at <$videoResource.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink

PS: I took the custom_header_video.html from the exampleSite's layout/partials folder.

ottlinger avatar Jul 20 '24 11:07 ottlinger

aye, we should prepare a github page with video cover, otherwise this get detected too late :/

zjedi avatar Jul 20 '24 21:07 zjedi

Unfortunately no image is rendered on the main page anymore - has the parameter/parameter names changed as well?

I had a look into the theme code and still saw:

  • header_image "/img/slide/slide01.jpg"

The referenced file is available under /public/img/slide but just not gets rendered/shown at all.

The image itself can be rendered locally via http://localhost:1313/img/slide/slide01.jpg but no markup is rendered containing any reference to the image.

ottlinger avatar Jul 20 '24 22:07 ottlinger

I found a hacky workaround to get my background back ....

  • define a custom_header_video and enable video rendering in _index.md
  • remove all the permalink stuff (Go template part)
  • link to background image in video*s poster attribute
  • provide a link to a video via source that does not exist

Voila - the background is shown!

ottlinger avatar Jul 20 '24 22:07 ottlinger

Unfortunately no image is rendered on the main page anymore - has the parameter/parameter names changed as well?

I had a look into the theme code and still saw:

* header_image "/img/slide/slide01.jpg"

The referenced file is available under /public/img/slide but just not gets rendered/shown at all.

The image itself can be rendered locally via http://localhost:1313/img/slide/slide01.jpg but no markup is rendered containing any reference to the image.

I can reproduce this issue and found that commit 4191af692faffb7e83dfb0417fb68392f7df32b7 introduced this behavior. You can test it yourself quite easily:

cd themes/hugo-scroll/
git checkout a1772f49e4491e1fce510fdd21e4f3b8ebf0294c
cd ../..
hugo

a1772f49e4491e1fce510fdd21e4f3b8ebf0294c is the commit before the multi language patch. Using 4191af692faffb7e83dfb0417fb68392f7df32b7 or newer I'm unable to view the defined header_image, it's not referenced anywhere after generating the public pages.

FFMbyBicycle avatar Oct 04 '24 14:10 FFMbyBicycle

I am encountering this issue as well.

Previous versions worked, header_image rendered. File content/_index.md contains the following lines:

header_image: "images/cover-image.jpg"
header_logo: "images/header-logo.jpg"

Navigating to http://www.example.com/images/cover-image.jpg or http://www.example.com/images/header-logo.jpg renders both images. Viewing the page source shows the following:

<head>
[...]
<meta property="og:image" content="https://www.example.com/images/cover-image.jpg">
[...]
<meta name=twitter:image content="https://www.example.com/images/cover-image.jpg">
[...]
<meta itemprop=image content="https://www.example.com/images/cover-image.jpg">
[...]
</head>

Using the instructions from @FFMbyBicycle to revert back to a last known good commit 4191af6 then viewing source provides the following:

<meta property="og:image" content="http://localhost:1313/images/cover-image.jpg">
<meta name="twitter:image" content="http://localhost:1313/images/cover-image.jpg">
<meta itemprop="image" content="http://localhost:1313/images/cover-image.jpg">
[...]
<header id="site-head" class="withCenteredImage" style="background-image: url(/images/cover-image.jpg)">

This header element is not being rendered by subsequent releases.

instantdreams avatar Nov 01 '24 19:11 instantdreams

Additional investigation

Previous version:

<header id="site-head" class="withCenteredImage" style="background-image: url(/images/cover-image.jpg)">
[...]
<div id="site-head-content" class="inner">
[...]
<a class='fn-item' item_index='7' href='./#site-head'>Return To Top</a>

Current Version:

<header id=site-head class=withCenteredImage>
[...]
<div id=site-head-content class=inner>
[...]
<a class=fn-item item_index=7 href=./#site-head>Return To Top</a>

I note that my hugo.toml contains the line:

    image_options = "webp q90 lanczos photo"

But I do not expect this to affect the render.

It looks like layouts/index.html is where the issue may be.

instantdreams avatar Nov 01 '24 20:11 instantdreams

According to reported bug analysis, the problem originates from https://github.com/zjedi/hugo-scroll/pull/177/files#diff-96762550561f76f989ced99c4a0751e94696682490ee94b2d77a66377c9619eb @ilja-radusch does it ring any bells?

zjedi avatar Nov 04 '24 20:11 zjedi

From a CSS point of view, the header tag still has the background-image like before. Just not defined through unsafe-inline but the style-Tag to also allow for different image sizes depending on screen size. For mobile phones this avoids downloading a big desktop version of the image.

depending on the implementation of the image slider this might break, if I.e. not all media query images are changed for the sliding. Technically the desktop images might still be sliding but are just not displayed on smaller screens. ;-)

To see which solution should be applied, I would would need an example site.

ilja-radusch avatar Nov 04 '24 21:11 ilja-radusch

Steps to reproduce the issue:

mkdir example-com
cd example-com
git init
hugo new site site
git submodule add https://github.com/zjedi/hugo-scroll.git site/themes/hugo-scroll
cd site
notepad++ hugo.toml

Add following details to hugo.toml:

baseURL = "https://www.example.com"
languageCode = "en-ua"
title = "Example Web Site"
timeZone = "America/New_York"
disableKinds = ["section", "taxonomy", "term", "RSS", "robotsTXT"]
defaultContentLanguage = "en"
theme = "hugo-scroll"
enableGitInfo = false
enableEmoji = true
[params]
    favicon = "images/favicon.ico"
    images = ["images/cover-image.jpg"]
    title_guard = true
    title = "Example Web Site"
    description = "The Example Web Site"
    language_menu = false
    show_current_lang = false
    copyright = "&copy; Example"
    hidedesignbyline = false
    invertSectionColors = false
    image_options = "webp q90 lanczos photo"
    combine_page_and_site_title = false    
    [params.footer]
    showContactIcons = false
    showFooterLinks = false

Create home page

hugo new content content\_index.md --kind home
notepad++ content\_index.md

Add following details to content_index.md:

---
header_image: "images/cover-image.jpg"
header_logo: "images/header-logo.jpg"
header_headline: "The Example Web Site"
header_subheadline: "A very good subheading"
header_use_video: false
nav_to_top_title: "Return To Top"
nav_to_top_weight: last
---

Copy over static assets:

mkdir static\images
cp /example/static/favicon.ico static/images
cp /example/static/images/cover-image.jpg static/images
cp /example/static/images/header-logo.jpg static/images

Run server

hugo server

Browsing to http://localhost:1313/ displays no background image: image

Source code view confirms the class withCenteredImage: image

instantdreams avatar Nov 04 '24 21:11 instantdreams

Note that this is tested in desktop mode using Firefox. The same result is obtained with Chrome and Edge.

instantdreams avatar Nov 04 '24 21:11 instantdreams

@instantdreams Is it problem only with local deployment? When you publish the site, is it ok?

zjedi avatar Nov 05 '24 09:11 zjedi

The issue can be reproduced locally and when deployed. The code generated is the same.

For reference, image properties:

  • cover-image.jpg, 4502 x 3164, 300 dpi
  • header-logo.jpg, 3784 x 3784, 300 dpi
  • favicon.png, 48 x 48, 32 bit depth

instantdreams avatar Nov 05 '24 19:11 instantdreams

My workaround does not work with the latest version of the theme - no video is rendered anymore :( but a static image remains on the frontend page. Furthermore the footer/contacts icons are broken and do not get rendered anymore ..... this "feature" is also visible on the demo: footer does not contain contact icons/infos and the page itself contains 404-images.

ottlinger avatar Nov 20 '24 10:11 ottlinger

Any update on this issue?

instantdreams avatar Dec 17 '24 15:12 instantdreams

I ran into this issue as well. I found that the function to fetch an image from global resources--resources.Get--does not look in the static directory.

So I copied my images to the assets directory.

mkdir -p assets/img
cp static/images/*.jpeg assets/img/

I changed the prefix from images to img out of concern of name collision. Not sure if that would cause problems or not.

After that, I ran the build once, then hugo serve was showing my images again.

tdenny avatar Jan 24 '25 02:01 tdenny

I copies my images from site/static/images/ to site/assets/images/ and deployed to my test enironment. The cover image is now present. I'll promote these changes to my master branch.

Thank you @tdenny for discovering this - it still seems to be an issue with the hugo-scroll theme, I have another theme that uses images which are picked up from the static directory, so I hope the maintainers of hugo-scroll can investigate and resolve.

instantdreams avatar Feb 04 '25 16:02 instantdreams

@instantdreams as a maintainer, I am currently a bit overwhelmed, it may take some time till I get to it.

While I was testing extensively the i18n feature, it too noticed serving from static vs assets made a difference. But after a while researching, it looked like a Hugo feature. I'm surprised it worked for you elsewhere. Can you try with latest Hugo version? I did some experiments and behaviour changes across different Hugo versions

zjedi avatar Feb 19 '25 20:02 zjedi

I realised in my github actions that I had pinned my hugo version to 0.139.2 so I updated it to latest and delete site/assets/images/. Just pushing to my test branch right now... Successful built with 0.144.2 and automatic deployment to my host.

On viewing the deployed static site, there is no background image or other site images served.

instantdreams avatar Feb 20 '25 22:02 instantdreams