Fix tags/changefreq/priority leaking into rendered page output

A Twig {% block %} always emits its content wherever it's declared -
wrapping novaconium/pages/_layout/layout.twig's metadata-only blocks
(tags/changefreq/priority) in a plain {# #} comment doesn't suppress
that, and a literal {% block %} tag inside a {# #} comment doesn't even
compile (comments are stripped before parsing). Both bugs were present:
the first caused "monthly 0.5" to appear as visible text in <head> on
every page; fixing that by wrapping the blocks in a real HTML comment
tripped the second, a Twig SyntaxError, because the explanatory comment
above them contained literal {% %}/{# #} sequences that terminated the
outer Twig comment early.

Fixed by wrapping the three blocks in an actual HTML comment (invisible
to a reader/browser, still genuine Twig blocks - overridable and
harvestable via renderBlock() exactly as before) and rewriting the
explanatory comment without embedding literal Twig delimiter syntax.
Verified the fix doesn't regress ContentIndexer's metadata extraction.
This commit is contained in:
code
2026-07-14 18:01:30 +00:00
parent 37b6764431
commit a51faa7208
+14 -5
View File
@@ -11,14 +11,23 @@
<link rel="canonical" href="{% block canonical %}{{ request_path|default('/') }}{% endblock %}"> <link rel="canonical" href="{% block canonical %}{{ request_path|default('/') }}{% endblock %}">
<link rel="icon" href="/favicon.ico"> <link rel="icon" href="/favicon.ico">
{# tags/changefreq/priority are never output as HTML — declared here {# tags/changefreq/priority (below) are metadata-only, not meant to be
only so they're overridable per-page (same mechanism as every SEO visible on the page. A block tag always emits its content wherever
block above) and harvestable by ContentIndexer via Twig's it's declared, though — and a Twig comment tag can't wrap a block
renderBlock() API, not rendered into the page itself. See tag (Twig comments are stripped before parsing, so a nested block
/admin/docs/content-index. #} tag inside one would never compile; don't put literal Twig
delimiter syntax inside a Twig comment's text either, for the same
reason — it terminates the comment early). So these three are
wrapped in a real HTML comment instead: invisible to a
reader/browser, but still genuine Twig blocks, overridable per-page
and harvestable by ContentIndexer via Twig's renderBlock() API
exactly like every SEO block above. See /admin/docs/content-index. #}
<!--
{% block tags %}{% endblock %} {% block tags %}{% endblock %}
{% block changefreq %}monthly{% endblock %} {% block changefreq %}monthly{% endblock %}
{% block priority %}0.5{% endblock %} {% block priority %}0.5{% endblock %}
-->
{# Open Graph / Facebook #} {# Open Graph / Facebook #}
<meta property="og:type" content="{% block og_type %}website{% endblock %}"> <meta property="og:type" content="{% block og_type %}website{% endblock %}">