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

Prevent resource publishing if only its .Content is outputted. #4944

Closed
regisphilibert opened this issue Jul 13, 2018 · 7 comments · Fixed by #5549
Closed

Prevent resource publishing if only its .Content is outputted. #4944

regisphilibert opened this issue Jul 13, 2018 · 7 comments · Fixed by #5549

Comments

@regisphilibert
Copy link
Member

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.

@earthboundkid
Copy link
Contributor

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.

@earthboundkid
Copy link
Contributor

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.

@regisphilibert
Copy link
Member Author

regisphilibert commented Jul 16, 2018

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’t want both your SCSS files and their processed CSS to be published. I know I don’t.

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.

@earthboundkid
Copy link
Contributor

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

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.

@bep
Copy link
Member

bep commented Jul 16, 2018

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.

@stale
Copy link

stale bot commented Nov 13, 2018

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.

@stale stale bot added the Stale label Nov 13, 2018
@stale stale bot removed the Stale label Nov 13, 2018
@stale stale bot removed the Stale label Nov 13, 2018
@bep bep added this to the v0.53 milestone Nov 13, 2018
bep added a commit to bep/hugo that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

Fixes gohugoio#4944
bep added a commit to bep/hugo that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

Fixes gohugoio#4944
bep added a commit to bep/hugo that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

Fixes gohugoio#4944
bep added a commit to bep/hugo that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

Fixes gohugoio#4944
bep added a commit to bep/hugo that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

This means that, for a transformed resource to be published to `/public`, you need to access either `.RelPermalink` or `Permalink`.

Fixes gohugoio#4944
@bep bep closed this as completed in #5549 Dec 21, 2018
bep added a commit that referenced this issue Dec 21, 2018
That is, if only `.Content` is accessed.

This means that, for a transformed resource to be published to `/public`, you need to access either `.RelPermalink` or `Permalink`.

Fixes #4944
@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 Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants