Open aubergene opened 6 years ago
Same here! Besides @aubergene 's use for comments, which is impossible in Sapper's current state, WhatsApp link sharing only understands og:image
if its meta tag is formatted with commas:
<!-- This works, WhatsApp reads into the comments -->
<meta property=og:image content=https://biptt-dev.netlify.com/ogImageSquare.png >
<!-- <meta
property="og:image"
content="https://biptt-dev.netlify.com/ogImageSquare.png"
/> -->
<!-- This doesn't work (line below unchanged) -->
<meta property=og:image content=https://biptt-dev.netlify.com/ogImageSquare.png >
<!-- Now it works (has commas) -->
<meta property="og:image" content="https://biptt-dev.netlify.com/ogImageSquare.png" >
See for yourselves with the minified version and the formatted version (grab the URLs and share them on WhatsApp, the image won't show up).
This is very grave and might be hurting tons of websites' conversions as social sharing is a big aspect of driving people to the site.
The quick-fix should be easy: just set removeAttributeQuotes: false
in html-minifier
's configuration! I will make a PR tomorrow if I have the time 😉
As to a more long-term solution, I'd say we follow Julian's idea of exposing the html-minifier
configuration :)
A really non-recommended workaround for the ones who really needs this...
node_modules/sapper/dist/minify_html.js
to your tasteyarn export
Again: not recommended. Do by your own risk.
Another option if you're between a rock and a hard place is to monkey patch it on post install:
"postinstall": "mv src/minify_html.js node_modules/sapper/dist/minify_html.js"
Currently the HTML minify config is hard coded. I need to use SSIs in my template, so I'm using a fork. It would be good to be able to change the config with a Sapper project, but I wasn't sure the best way to enable this.