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:
@@ -11,14 +11,23 @@
|
||||
<link rel="canonical" href="{% block canonical %}{{ request_path|default('/') }}{% endblock %}">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
|
||||
{# tags/changefreq/priority are never output as HTML — declared here
|
||||
only so they're overridable per-page (same mechanism as every SEO
|
||||
block above) and harvestable by ContentIndexer via Twig's
|
||||
renderBlock() API, not rendered into the page itself. See
|
||||
/admin/docs/content-index. #}
|
||||
{# tags/changefreq/priority (below) are metadata-only, not meant to be
|
||||
visible on the page. A block tag always emits its content wherever
|
||||
it's declared, though — and a Twig comment tag can't wrap a block
|
||||
tag (Twig comments are stripped before parsing, so a nested block
|
||||
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 changefreq %}monthly{% endblock %}
|
||||
{% block priority %}0.5{% endblock %}
|
||||
-->
|
||||
|
||||
|
||||
{# Open Graph / Facebook #}
|
||||
<meta property="og:type" content="{% block og_type %}website{% endblock %}">
|
||||
|
||||
Reference in New Issue
Block a user