Hi there,
How can i tell hugo to not remove or minify the below html tag
<!--sse-->This text conditional <!--/sse-->
Thanks
Hi there,
How can i tell hugo to not remove or minify the below html tag
<!--sse-->This text conditional <!--/sse-->
Thanks
See:
Configure Minify
maybe that help.
You can keep comments, but doubt you can just specify what need and what don’t to be minified.
[minify.tdewolff.html]
keepComments = false
Hi @idarek
Turning comments off is one way. However, this is not the traditional comment. It serves as a wrapper to conditionally display specific text to site visitors while hiding it from bots.
Is there anything available that indicates to Hugo that this comment is essential and shouldn’t be changed or removed? or whitelist specific HTML tags to indicate that the code <!--sse-->
should not be changed.
Thanks
Try
keepConditionalComments = true
and modify your code to use conditional comments
But that’s not a good solution and doubt that there are. Comments are for comments. If you using this for other purposes, there are other tags that you can use that you can display: hidden
from visitors etc.
{{"<!-- Your comment here -->" | safeHTML }}
?
Hi @idarek
I am using Cloudflare. Cloudflare decides if the visitor is a bot or not, and accordingly displays the conditional content. Cloudflare has a very specific tag you have to use, which is <!--sse-->
.
If at all possible, an exception to this rule will enable the addition of conditional comments while maintaining the other optimizations for comment removal and minification.
Thanks
Replace the exclamation mark with its HTML entity.
In a template:
{{ "<!--sse-->foo<!--/sse-->" | safeHTML }}
Thanks @jmooring
It works!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.