Hello. minify works okay, but my SEO engineers said that quotes must be in the meta tags. How can I save it?
In HTML5, you can use unquoted attributes (cf. https://www.w3.org/TR/html52/syntax.html#attribute-value-unquoted-state).
But it could be a nice idea to always quote attributes (cf. http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes)…
The quotes around tag attributes are not SEO relevant. The “engineers” (hihi, sorry) probably use tools that parse those tags and are unable to cope with this. In the end, it’s good for SEO if you have some bits and bytes shaved off.
I remember we had a post recently where the minifier removed an empty head tag. That is possible too in HTML5 (it’s not needed if it’s empty and it can be empty because nothing in there is required).
If it is absolutely an issue then you can have a post-script running and doing the minification. As @nfriedli linked above you can set the configuration to leave quotes in.
Aggressive stripping of quotes and tags is premature optimization as far as I’m concerned. Regardless of what the HTML5 spec allows for, consistent API usage is always a good thing. The savings in stripping a few tags and quotes is nothing compared to:
- Unknown effect on device compatibility
- Potential SEO implications
- Negative impact on social sharing
- Negative effects on parsing & DOM traversal tools
Or any number of other factors. It is akin to JS devs taking advantage of ASI and leaving out semicolons. It’s inconsistent, at best. At worst, it breaks something somewhere…
I could not find any way to pass a flag along with the
--minify command, to disable quote stripping.
Although I realize it might be overly complicated and not realistic for some people’s build pipelines, my recommendation would be to handle it after build. Just use Node and something like HTMLMinifier. If you work with Gulp, gulp-htmlmin is a solid option, easy to use, AND consistent in my experience.
I love the idea of native Hugo minification, but conservative and consistent output is more important to me.
Yes, I also think. I would like to find an option for html compression, but with the quotation marks preserved. My optimization experts also rely on this.
It would be great to add the ability to compress content while keeping quotes in HUGO.
@Travis Premature optimization is when you optimize your code without measuring it and without knowing whether it has a real impact. The removal of quotes is one of the big contributors to HTML minification that has been well tested and is one of the main objectives of the HTML minifier.
The problem is that you assume that minified HTML should somehow follow arbitrary rules for readability (e.g. consistent quote usage), which I would agree with if it were not that minified HTML is supposed to be read by machines only. Parsers that are compliant with the HTML5 spec (i.e. machines) are the only ones that will read minified HTML5. If following the official HTML5 specification is not consistent, I don’t know what is. If you think readability is a problem, you are missing the point.
If you have problems with device compatibilty, SEO implication (this point is moot, there are no search engines that outdated), social sharing or DOM tools, it means you are using old software that implements HTML4. Please update your toolset, but you probably shouldn’t bother optimizing your website anyways.
In short, if you think minification is “bad”, please don’t use it. But stop spreading nonsense if you don’t know what you’re talking about.
@igramnet If your optimization experts rely on quotes, please urge them to use a HTML parser (one of many open source). I assume they instead rolled their own regular expression pattern (which is a bad idea!) and assume they’re dealing with XML? XML and HTML are very different.
@pkollitsch is right. Also @nfriedli makes a fair point, but the potential problems that are mentioned in the article have all been carefully taking into consideration, so that should not pose a problem.
I agree with you. However, on his own site, he was convinced that by returning the quotes Google became better at indexing it. However, nothing else was done on the site. That is why I ask you to add a flag that would leave quotation marks during minification.