Try my suggestion first and then if it works -as I described above- mark it as the solution, so that people who might read this forum topic, know that this is how Go templates handle strings.
The problem for me was to understand the root of this weirdo. As you saw, not an easy trip.
Once I understood, workaround where simple.
You gave me the light ( … and there where light …) when you ask to have exacty same code on home and section. This was the declic as I have to take care of other partials.
yes, and a big thank you for your help & time. Really.
Problem was an apostrophe ' in the HTML comment (because in a go template), while putting this in go-template beetween double quote ".
This make the parser go wrong for some case.
Workaround was either :
to remove the faulty apostrophe '
to enclose the comment in backticks ` instead of double quote ".
or better solution™ by Bep : remove the line. Same thing as in the movie “Speed” : remove the hostage from the situation by shooting the hostage in the leg.
But the main point was to understand where the problem was.
Because this problem was belonging to an other template
Same like a huge leak on your house east wall. After scrapping the wall you discover that the root cause is on the east side of rooftop
As I said above Go templates interpret strings enclosed in double quotes, hence the error for the extra single quote (meant as an apostrophe), despite the valid go/HTML comment.
This is how Go templates operate.
To use literal (uniinterpreted) strings one must enclose them in backticks.
This is not related to Go templates etc. This is my fault … We look for HTML elements, but skip any string inside quotes; in this case the parser found an opening quote, but no closing, so it skipped to the end …
So, the reason we’ve not seen this bug before is probably that Go templates do remove HTML comments, but not in the way it’s added here.
Personally
I really like template comments in templates, use them all the time
But my use case (not a huge needs tho) is that my websites are for other non technical people (my daughters, my friends, etc …).
And I wanted to give a hint about where are the sources of what they want to change by themself (if easy).
So the HTML comment (the one who will stay in the final html code) was the tool I choosed to lead them on the right path of the source. My sites/themes scan be quite sophisticated in their organisation. I want to avoid a 30page notice
But as said, just I was not aware about all those impacts. I will change whatever is needed & adapt to what is logic and rock solid.
Here we can see the main difference between northern people (rational, transparent, efficient, no fear of telling about mistakes, etc …) and French people, like for example our beloved President who recently claimed that “I would not say it’s a failure : it didn’t work”.
In any case I have switched to using backticks for most of my use cases in Hugo templates and this approach has saved me from several time consuming quirks or bugs like this one that @divinerites has encountered.