This minifier will delete your html, head, and body tags by default.
It will also delete a lot of other tags, as well as conditional comments (IE-related).
The developer of this minifier is somewhat confused. He reads one of the HTML specs (there are two), and when he sees that an element/tag is specified as “optional”, he thinks this means that a minifier should delete it by default. He places his idiosyncratic spec-reading above conformance with the web as it is in reality, and takes huge risks with other people’s HTML, CSS, etc. And if something isn’t in the spec, like conditional comments, he thinks he should just delete it… (Conditional comments are becoming less and less relevant, but if they’re in someone’s code, they put them there for a reason, perhaps knowing their user base is some enterprise or state government that still has older versions of IE or something. There are a million different contexts out there, and if conditional comments are deliberately placed in the HTML source, they’re there for a reason and should be left alone by default.)
He also doesn’t understand that browsers are not the only consumers of HTML or of websites. I’ve tried to explain this to him. The spec is really only about browser rendering. The head tags encapsulate a lot of metadata for FB, Twitter, Schema.org, Google’s bot, AMP’s CSS, etc and some of those services won’t parse your metadata if it’s not wrapped in head tags. It’s just incredibly reckless to delete your html, head, and body tags and expect your website to work normally, or for SEO and social media metadata to work. It doesn’t matter that an HTML spec calls those tags “optional”. The spec is written for browsers and what they should render – it doesn’t anticipate the metadata situation we have on the modern web, and “optional” doesn’t mean “delete it when you see it”.
There were comments on the Caddy discourse that talked about the minifier breaking sites, some of which might have been censored or deleted. This is a bad minifier, and it seems to keep popping up in Go projects simply because it happens to be written in Go. We need a new minifier if we want safety and rigor.
I use the same minify to minify all of the HTML in the public dir, and I use the Twitter and opengraph meta tags, and they all work fine (Twitter cards render fine, etc.). See https://scripter.co and look the the head tag for one of the posts.
What missing/deleted tags are you complaining about?
As for the deletion of conditional comments for IE, I couldn’t care less. I don’t even bother to have IE compliant CSS on my site.
Perhaps not. I assume the minifier is used to minify the pages and assets. I saw a new pipeline feature with a minifier. In Hugo’s GitHub repo I saw that the minifier in use was https://github.com/tdewolff/minify
What am I missing? Why did you rewrite the title of my post?
I don’t understand. It’s in the pipeline now. The latest release says “Hugo 0.43 adds a powerful and very simple to use Assets Pipeline with SASS and SCSS with source map support, PostCSS and minification and fingerprinting and Subresource Integrity and … much more.”
@JoeWeb We will eventually write solid documentation where this will eventually be more clear. Until then, I will ask you to try it out. Try to understand how a new feature works before you start bashing it. People, me included, have spent lots of hours working on this – including researching minifier libraries.
I will close this thread now. Pleas open up another one if you have problems getting this working.