9

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 %}

1 Answer 1

31

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.