I want to exclude the partials adsense.html and analytics.html from some pages (for testing load performance i.e.). Rather than setting a Param to include it I set one to exclude it. It works, but I feel it’s not the correct way.
For *.md pages that I want to exclude the code:
---
google: false
---
In head.html
{{ if eq .Params.google false }}
{{ else }}
{{partial "analytics.html" .}}
{{partial "adsense.html" .}}
{{ end }}
A bit off topic. I would strongly recommend you to resign from AdSense in lieu of other solutions. You using Hugo to get performance boost and good Core Web Vitals where AdSense will kill that.
Have to add, once one gets the basic idea how Hugo works it’s quite easy to implement whatever js/jquery wizardry you see somewhere.
An off-topic update. I tried THIS METHOD with the Hugo Youtube shortcode and there wasn’t really a difference. Put this code speeds youtube links up a lot: GitHub - paulirish/lite-youtube-embed: A faster youtube embed.
In PageSpeed numbers for a page with only some HTML and one Youtube embed::
62 Hugo Shortcode
64 Hugo Shortcode + Lazy Wrapper
100 Paul Irish Github code
But note that the Paul Irish code does not display the title.