gohugoio / hugo

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

Double mounting content into assets does not live reload content changes #12838

Open jsmolka opened 1 month ago

jsmolka commented 1 month ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.134.1-2f89169baa87a9db47e288b60705f4e99e21a945+extended windows/amd64 BuildDate=2024-09-05T10:17:50Z VendorInfo=gohugoio

I am using Windows 10.

Does this issue reproduce with the latest release?

Clone and setup my blog.

git clone https://github.com/jsmolka/blog
cd blog
npm i
hugo server -F -D

Then change the content of any markdown file. Hugo detects the change, but it's not visible in the browser. Even reloading the page doesn't reflect the changes. I doesn't work with Chrome and Firefox. I need to restart hugo to see the changes. I had this issue for a while and stayed on a older hugo version, hoping for the fix. It stopped working when upgrading from v0.122.0 to v0.123.0.

Hope this helps, thanks for the otherwise great library.

jmooring commented 1 month ago

This mount is causing the problem:

[[module.mounts]]
source = "content"
target = "assets"

If you remove the above from your site configuration, the rebuild works as expected.

I understand what you're trying to do (make every page resource available as a global resource), but I wouldn't do that.

jmooring commented 1 month ago

Failing test:

func TestRebuildIssue12838(t *testing.T) {
    t.Parallel()

    files := `
-- hugo.toml --
disableKinds = ['page','section','rss','sitemap','taxonomy','term']
[[module.mounts]]
source = 'content'
target = 'assets'
-- layouts/index.html --
{{ .Content }}
-- content/_index.md --
foo
    `

    b := hugolib.NewIntegrationTestBuilder(
        hugolib.IntegrationTestConfig{
            T:           t,
            TxtarString: files,
            NeedsOsFS:   true,
            Running:     true,
        }).Build()

    b.AssertFileContent("public/index.html", "foo")

    b.EditFiles("content/_index.md", "bar").Build()

    b.AssertFileContent("public/index.html", "bar")
}
jsmolka commented 1 month ago

Thank you. I can't really remember what I was trying to achieve there, but I removed the mount and everything works again.