Is this worth mentioning in the docs?

I added the assets folder as a static folder in the config file and this broke live changes for the CSS and JS files in that folder that used resources.Get. Is it worth mentioning in the docs about avoiding using assets as a static folder? It took me a few weeks to find this.

If you change the default assets directory to serve static content instead, I think that the behavior you see is expected, especially if you are using assets features like resources.Get.

1 Like

How did you do this? Please post your configuration.

This way staticDir = ['assets'] (I have since removed the code and moved anything other than CSS and JS to the static folder)

Just for reference:

  • assetDir is used to set the global resources directory. Stuff you would resources.Get and such should be put in this dir.

    Default value: assetDir = "assets"

  • staticDir1 is a list of directories to be used for serving static content directly at the base of the published site i.e. directly under public/.

    Default value: staticDir = ["static"]


1 Oddly, staticDir is not documented in the list of site config variables.

1 Like

you will find something here

1 Like

@ju52 Thanks. I happened to find that same link and had hyperlinked that variable name to that. I first searched in same page where assetDir is documented, but couldn’t find staticDir there.

1) This is not the expected behavior
2) Doing the reverse has the same effect
3) You get the same results using [[module.mounts]]
4) The site builds as expected
5) The problem is limited to running hugo server
6) This is a known issue: https://github.com/gohugoio/hugo/issues/7740
7) No, I don’t think this is worth mentioning in the docs

While I do not understand why you would want to mount assets->static, I certainly understand the need/desire to mount static->assets.

Does that mean I can’t use the assets folder as an asset and static directory?

That was not the intended behaviour. I wanted to only have one static folder after seeing a reply in this forum that the assets folder can be used as a static folder. So I put everything in there.

As you are now aware, these two directories have very different purposes.

There are approximately 37k topics in this forum, dating back to 2014. If there are, on average, 5 posts per topic (probably a low estimate), that’s about 185k posts:

  • Some are correct
  • Some are correct under certain conditions
  • Some are correct within a limited functional scope
  • Some are correct if you are willing to live with the consequences
  • Some were correct at the time they were written
  • And some are just… wrong (guesses, untested code, fundamental misconceptions, answering the wrong question, etc.)

Caveat emptor.
Doveryai no proveryai.

That again takes me back to my first question that there needs to be specific info that the assets folder should not be used as a static folder if someone is using Hugo Pipes. I will close this now since it seems my case was an outlier.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.