Let's mold the clay

A good base template shouldn't have anything other than blocks. This means that if you have a class name or ID name defined in your base template, then you need to reconsider your structure. Yes, your code still works but it does not follow the best practices. Remember, a base template is supposed to define the structure only. So, all styling or functional-related contents should be kept in the children templates that extend the base.

Keeping this in mind, let's modify the default base template a little:

{# app/Resources/views/base.html.twig #} <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <title>{% block title %}{% endblock %}</title> {% block head %}{% endblock %} </head> <body> {% block navigation %}{% endblock %} ...

Get Mastering Symfony now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.