Search code examples
phpsymfonytemplatestwigtwig-extension

bootstrap isn't working in symfony template


I'm working on a symfony project. I have this base.html.twig and a page that extends from it.

This is base.html.twig:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{% block title %}PFE{% endblock %}</title>
        {% block stylesheets %}    <link rel="stylesheet" href="css/bootstrap.min.css"/>{% endblock %}
    </head>
    <body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <a class="navbar-brand" href="#">Projet de fin d'etude</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarColor01">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href={{ path('main') }}>Menu principal <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href={{ path('cours') }}>Liste des cours</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href={{ path('professeur') }}>Liste des professeurs</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href={{ path('departement') }}>Liste des departements</a>
                </li>
            </ul>

        </div>
    </nav>


        {% block body %}

        {% endblock %}

        {% block javascripts %}
            <script src="/>js/jquery.js"></script>
            <script src="/>js/popper.min.js"></script>
            <script src="/>js/bootstrap.js"></script>
        {% endblock %}
    </body>
</html>

and this is the template that extends it:

{% extends 'base.html.twig' %}
{% block title %}ajouter un nouveau cours{% endblock %}
{% block body %}
    {{ form(formCours) }}
{% endblock %}

Base is working on other template but why isn't working on this?

Here is a screenshot for two pages:

enter image description here

but in the template that extends I got this:

enter image description here

Can someone solve this problem please?


Solution

  •         {% block stylesheets %}    <link rel="stylesheet" href="/css/bootstrap.min.css"/>{% endblock %}