gohugoio / hugo

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

Add mount.disableWatch config option #12589

Closed bep closed 6 days ago

bep commented 2 weeks ago

https://gohugo.io/hugo-modules/configuration/#module-configuration-mounts

This idea came when working on #8086.

We need to think a little before doing this, but it would probably be really useful and mind-twisting if I could do:

[module]
  [[module.mounts]]
    source = 'public'
    target = 'assets/public'
    disableWatch = true

And then in a template:

{{ with (defer (dict "key" "foo") }}
    {{ $jsonFilePublic := resources.Get "public/mysection/index.json" }}
    ...
{{ end }}

@jmooring do you

  1. See the same potential/usefulness as me?
  2. See any (serious) pitfalls?

I have quickly tested it, and the only issue I have seen is that the mount setup checks to see of source exist before it mounts it, but that's fixable.

jmooring commented 2 weeks ago

Although I haven't given it a lot of thought, I haven't come up with any exciting use cases for defer blocks either with or without mounting the public directory to something.

I know that #8077 was one of the motivators for defer blocks, but that was before we introduced Page.Store and documented output format weighting. The backlinks approach described here might be easier to understand if it were rewritten using a defer block per your example above... you could write the data to file instead of stuffing it into a home page Store.

To your original questions...

See the same potential/usefulness as me?

Not yet.

See any (serious) pitfalls?

No.

bep commented 2 weeks ago

I know that https://github.com/gohugoio/hugo/issues/8077 was one of the motivators for defer blocks

I think I would rather call it "an example use" for defer blocks. Back links isn't something I'm terribly exited about, but to be effective at scale, it needs some "first class" support in Hugo.

As to defer, a cleaner way of doing what resources.PostProcess does today is plenty worth it. And then comes JS splitting.

As to this particular issue, I'm having trouble finding useful examples, so I'll let it linger.