About the minifier used in Hugo Pipes in a totally unrelated context

Hi all – The new pipeline stack appears to be using this minifier: https://github.com/tdewolff/minify

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.

1 Like

I’m using html-minifier with node. Wrote a post about this: Hugo 0.43 Asset Pipeline: Minify HTML and concat JS files

@JoeWeb do you understand how the minifier is used in Hugo?

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.

1 Like

Just to ellaborate a little: The thread starter mainly complains about the particular minifier implentation’s removal of HTML tags.

It is currently not possible to minify the rendered HTML output from Hugo.

1 Like

That’s what I found out as well. As I said: html-minifier works very well.


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?

Once specific complaint was that Google’s bots weren’t indexing the page properly without the head tags, or possibly the combo of no head tags and no html tags.

Your title was screaming and misleading on a fundamenetal level. Read my sentence in bold above.

Did you see that? So how are you able to use minify in Hugo for HTML minification?

The minify tool has options to keep the document tags, and other things. These could be made configurable if Hugo were to ever use it to minify the rendered HTML output.

The is the command I use for my rendered HTML output: minify --type html --html-keep-document-tags --html-keep-default-attrvals

1 Like

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.”

(Bold added)

So what are you guys talking about?

So you didn’t even try using the minification feature from Hugo 0.43? :slight_smile:

You’ll know what we are talking about as soon as you try it.

@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.