Nesting block tags doesnt work I have pagination twig component that needs to inject seo links into  of page (rel canonical).

I tried to use {% block %} twig tag for this, but problem is that pagination component is already included in another {% block %} tag containing main content of page.

In short, im trying to do this:

layout.twig:

&lt;html&gt;
&lt;head&gt;
{% block seo %}{% endblock %}
&lt;/head&gt;
&lt;body&gt;
{% block main %}{% endblock %}
&lt;/body&gt;
&lt;/html&gt;


page.twig:

{% extends 'layout.twig' %}

{% block main %}

some content..
{% include 'pagination.twig' %}

{% endblock %}


pagination.twig:

... pagination links

{% block seo %}
&lt;link href="url" rel="canonical"&gt;
{% endblock %}


When im using this code, block seo is empty. 
Can this be achived some other way?
Unfortunately it’s not possible for an included template to override the contents of a block in the parent template, or its layout.

You’d need to just override the seo block from page.twig do whatever you need to do from there instead.

{% extends 'layout.twig' %}

{% block main %}
  some content..
  {% include 'pagination.twig' %}
{% endblock %}

{% block seo %}
  &lt;link href="url" rel="canonical"&gt;
{% endblock %}