-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
“hugo --minify” strips spaces and preserve some new lines #6892
Comments
yes me too, but this just happen on |
Fixes gohugoio#6750 Updates gohugoio#6892
Fixes gohugoio#6750 Updates gohugoio#6892
I want to clarify that "newlines are not minified" is incorrect. The minifier removes superfluous whitespace, but sometimes whitespace in HTML has meaning and cannot be removed. In that case either a space or a newline are required, and both have the same effect. The minifier will let the remaining significant whitespace be a newline when any of the original whitespace characters contained a newline. This newline cannot be removed without changing the display of HTML. You second issue that whitespaces get remove in tags, this is because you use the CSS |
@tdewolff thanks for the input and your work on this, much appreciated. I have not looked into this particular issue, but we just merged way to configure and turn off a given minified, so that should solve most of these issues. |
@tdewolff Just a minify note. It appears that the first nested |
Thanks for that! I've fixed it in tdewolff/minify@8a5c9ca. Seems that both |
Will push one out soon, I'm very busy with work these weeks unfortunately :-( sorry about that |
@virgofx I had to revert to an older version of that library some time ago as it broke many sites in the wild. So we're currently a little behind. |
I've pushed out 2.7.4 |
Thanks @bugsysailor, fixed your issue in tdewolff/minify@7d9c460 Please remember that Hugo prevents removal of end tags. The default settings of the minifier will remove all superfluous |
Is there any way to get rid of the new lines with the current config settings? I've set all the "Keep…" options to false, although I still get new lines. My HTML/CSS is set up in such a way where it doesn't rely on whitespace so they aren't needed |
Some whitespace is significant in HTML, that whitespace character may be a space or a newline (both are 1 byte long). Eventhough your file contains newlines it may not be possible to further minify its contents. |
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. |
This issue has been marked as stale, but I am still experiencing this behavior with hugo 0.80. |
I still experience this as well, although I understand why it works like it does. I think what's needed is an option to disable the whitespace generated by newlines in the code. If I have:
in my HTML, I'm not saying I want a space between each HTML tag even if it appears that way on the page when there's no stylesheet, the newline generates whitespace that I don't want and I visually remove it with CSS. I would like an option for these tags to be on one line when minified with no whitespace between them. |
With the various comments since this issue was originally created, the scope and detail are no longer clear. It contains unrelated reports of problems and suggested changes. We bumped tdewolff/minify to the most current version (v2.9.15) with Hugo v0.82. Please test to see if your problem or enhancement has been addressed, and create new specific issues as needed. Please remember that minification has a number of configuration options: |
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. |
When I use hugo --minify in my branch/repo:
New lines not minified:
Space inside tag striped:
The text was updated successfully, but these errors were encountered: