Answer the question
In order to leave comments, you need to log in
What is the proper way to layer a basic jinja2 template (Flask/Django)?
Hello.
I break the base template (which is inherited by other templates) into functional parts (layers/layouts). It looks roughly like this:
base.html
<html>
<head>
{% include 'layouts/head.html'%}
</head>
<body>
{% include 'layouts/navbar.html'%}
<div class="container">
<div class="row">
<div class="col-12">
<h1>{% block title %}{% endblock %}</h1>
{% block content %}{% endblock %}
</div>
</div>
</div>
{% include 'layouts/footer.html'%}
{% include 'layouts/js.html'%}
</body>
</html>
...
<title> {% block title %}{% endblock %}</title>
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question