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

Live-reload does not detect new Page resources #4768

Closed
internetfreak opened this issue May 24, 2018 · 13 comments
Closed

Live-reload does not detect new Page resources #4768

internetfreak opened this issue May 24, 2018 · 13 comments

Comments

@internetfreak
Copy link

Related to this: https://discourse.gohugo.io/t/livereload-not-rebuilding-page-resources/11715/4

The issue
When using hugo with server mode for development reasons and you create a new page bundle, hugo notices the index.md file of the bundle and starts rendering it on changes. However, if you also add resources like images to that bundle, they won't be available in .Resources unless you restart the server, which slows down developement a lot.

Expected behavior
Adding resources to a page bundle should immediately populate .Resources to be retrieved using .Resources.Match or .Resources.GetMatch without requiring to restart the development server.

Envinronment informations
Version of Hugo: 0.40.3
OS: Windows 10 Pro x64

@bep bep changed the title Hugo server does not include page bundle resources unless restarted Live-reload does not detect new Page resources Jun 10, 2018
@bep bep added this to the v0.42 milestone Jun 10, 2018
@bep bep added the Bug label Jun 10, 2018
@bep
Copy link
Member

bep commented Jun 11, 2018

I just tested this with the latest Hugo master, and this works perfectly on macOS.

I tested this on https://github.com/bep/hugotest/tree/master/content/resourcemeta/bundle-with-resource-meta-toml (note that the last commit in this repo requires the latest Hugo dev version):

When server was running:

  • Copied a new PNG into that folder. PNG shows up with metadata supplied.
  • Delete the same PNG, it vanishes from page.

I tested the above OK on both current master and v0.40.3.

@bep
Copy link
Member

bep commented Jun 11, 2018

I have not also performed the same test on Windows 10. Works fine for me.

Can you try this one more time; and if this is still an issue, can you describe your steps in more detail so we can try to identify what happens.

@bep bep modified the milestones: v0.42, v0.43 Jun 11, 2018
@internetfreak
Copy link
Author

internetfreak commented Jun 11, 2018

I tested this again and I'm still able to reproduce using hugo 0.41 on Windows 10. Here are my steps to I did to test:

  1. Create a new hugo site
  2. Add the following templates:
    layouts/_default/baseof.html
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

        <title>
            {{ block "title" . }}
                {{ .Title }} | {{ .Site.Title }}
            {{ end }}
        </title>

        {{ range .AllTranslations}}
            <link rel="alternate" hreflang="{{ .Language }}" href="{{ .Permalink }}" />
        {{ end }}
    </head>
    <body>
        {{ block "content" . }}{{ end }}
    </body>
</html>```

**layouts/index.html**
{{ define "content" }}
{{ $posts := where .Site.RegularPages ".Type" "blog" }}
{{ range $index, $element := $posts }}
{{ $featuredImage := $element.Resources.GetMatch "images/hero-image.*" }}
{{ if $featuredImage}}
<img class="featured-post-image" src="{{ $featuredImage.Permalink }}" />
{{ end }}
{{ end }}
{{ end }}
  1. Create a new section called blog
  2. Start hugo by using hugo server --baseURL http://localhost
  3. Add a page bundle folder using any name
  4. Add the following minimal index.md
+++
title = "Test Pagebundle4"
draft = false
date = 2018-06-11T13:00:00+02:00
+++
This is a test of a pagebundle
  1. Add a folder called images inside of our bundle folder and add any image called hero-image in there. The file extension should not matter, I used a license free jpg I found on the internet
  2. Note how hugo detects every change we make but if you navigate to localhost:1313 or reload the page, should you already opened the url, then you notice that the page is still empty
  3. Stop hugo and restart it again in server mode. Reload the page and now you see the image being displayed

I hope this helps. As it is a very simple setup I did not create a github repo for this to checkout and reproduce.

@bep
Copy link
Member

bep commented Jun 11, 2018

As it is a very simple setup I did not create a github repo for this to checkout and reproduce.

As I said, I'm not able to reproduce it with a similar simple setup. So the devil is in the details. Someone may eventuallyt look closer into this, but if you can create a runnable GH repo, I can probably look at it sooner rather than later.

@internetfreak
Copy link
Author

I uploaded the complete working directory I used for testing (including the image, it's CC0 and thus safe to use and distribute) to github, here's the link: https://github.com/internetfreak/pagebundle-bug/tree/master

@timsluis
Copy link

timsluis commented Jun 27, 2018

The same is happening for me on macOS. Will try to look into it as well.

Environment information
Version of Hugo: 0.42.1
OS: macOS 10.13.5

@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep removed the CantReproduce label Jul 10, 2018
@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 12, 2018
@bep bep modified the milestones: v0.46, v0.47, v0.48 Aug 3, 2018
@bep bep modified the milestones: v0.48, v0.49 Aug 22, 2018
@bep bep modified the milestones: v0.49, v0.50 Sep 13, 2018
@Francoimora
Copy link

I have the same problem on windows and on a docker jojomi image (wich is on a synology nas running H24 in server mode). It's really super hard for us because we have a preview server running for non-dev to work before going to production and I can't say to them they have to restart the server everytime they add a resource to a page. Please fix this, it's there since I started using Hugo 4 months ago =/

@bep bep removed this from the v0.50 milestone Oct 6, 2018
@bep bep added this to the v0.101.0 milestone May 31, 2022
@bep bep modified the milestones: v0.101.0, v0.102.0 Jun 16, 2022
@bep bep modified the milestones: v0.102.0, v0.103.0 Aug 28, 2022
@bep bep modified the milestones: v0.103.0, v0.104.0 Sep 15, 2022
@bep bep modified the milestones: v0.104.0, v0.105.0 Sep 23, 2022
@bep bep modified the milestones: v0.105.0, v0.106.0 Oct 26, 2022
@bep bep modified the milestones: v0.106.0, v0.107.0 Nov 18, 2022
@bep bep modified the milestones: v0.107.0, v0.108.0 Nov 25, 2022
@bep bep modified the milestones: v0.108.0, v0.109.0 Dec 14, 2022
@jonsterling
Copy link

This is also happening to me on macos.

@jonsterling
Copy link

In case this is useful information, I am finding that I can't easily reproduce this bug anymore on the current version of Hugo. Wonder if others are having a similar experience.

@bep bep modified the milestones: v0.109.0, v0.111.0 Jan 26, 2023
@bep bep modified the milestones: v0.111.0, v0.112.0 Feb 15, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@jmooring
Copy link
Member

Unable to reproduce with v0.111.3 on Linux or Windows. If you cross file system boundaries you may need to use the poll flag:

hugo server --poll 700ms

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants