Is there anyway to repeat one block in twig like this:
<title>{% block title %}{% endblock %} | MyBusiness</title>
<meta name="title" content="{% block title %}{% endblock %} | MyBusiness"/>
In order to only declare the two blocks once? Like that:
{% block title %}
The title I want to show in each title and metaTitle tags.{{ parent() }}
{% endblock %}
You can use an already defined block by writing {{ block('blockName') }}
. So for your example you would do it like this:
<title>{% block title %}{% endblock %} | MyBusiness</title>
<meta name="title" content="{{ block('title') }} | MyBusiness"/>
See the documentation which points out nearly exact the same example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With