Hugo: Prevent resource publishing if only its `.Content` is outputted.

Created on 13 Jul 2018  路  6Comments  路  Source: gohugoio/hugo

Currently, a resource will be published even if only its .Content is outputted in the template (and not its .Permalink):

{{ (resource.Get "inline.scss" | toCSS).Content) | safeCSS }} 

I guess this could cost some build time in the rare case where a user needs to output both the .Content of a resource and its .Permalink.

Enhancement Keep

All 6 comments

Vice-versa, I was trying to move a site from my pre-43 system to post-43 and I ran into the issue that my font files were in a subfolder from my SCSS and so when I just moved the SCSS folder from static to assets the fonts ended up not being published, so I had to move the fonts back but leave the SCSS in assets. Now I have /static/scss/ with no SCSS in it. :-)

My preference is that everything in assets should be published and the main difference from static is just that it's available for post-processing, not that it must be post-processed in order to exist in the final build.

Another issue: My SCSS refers to a background image. Ideally, the background image should also be hashed somehow? But in any event, I also had to split the /static/images folder into two because the images that are referred to in the template need to be assets to be hashed, but the ones that aren't in templates need to be in static to be published.

Hi @carlmjohnson.

Files in the assets directory m should not be automatically published because a lot of them are there to be processed.
You don鈥檛 want both your SCSS files and their processed CSS to be published. I know I don鈥檛.

Furthermore this issue is about tightening the 芦聽publishing聽禄 rules for the assets, so your comments appear to be out of scope.

You do make an interesting case though and I encourage you to bring it up in the discourse if you have not done already.

You don鈥檛 want both your SCSS files and their processed CSS to be published. I know I don鈥檛.

Why not? The file size is probably trivial, and I'm not worried about someone hacking my site by reading the SCSS. :-) I do see the case for not wanting to publish, e.g., large images multiple times, but in general, I think there's no reason to publish it all by default.

My preference is that everything in assets should be published

That will never happen (for several reasons, but I'm not takin that debate -- but it is a fundamental difference between /static and /assets).

I think this was a "glitch in my implementation", as in -- it was meant to be the way @regisphilibert wants it.

And that is in line with what happens if you do $foo := resources.Get "somefile.js.

$foo will never get published until you either access $foo.RelPermalink or $foo.Permalink.

The transformed resources behave differently, possibly because of an implementation optimization -- I can create an io.MultiWriter and write to both memory and file at the same time.

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digitalcraftsman picture digitalcraftsman  路  3Comments

artelse picture artelse  路  3Comments

vielmetti picture vielmetti  路  3Comments

geddski picture geddski  路  3Comments

antifuchs picture antifuchs  路  3Comments