Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmatthias papsdorf
Courses Plus Student 4,152 Pointsdefining the scripts block in index.html?
Hey there,
I was just wondering. Since I want to define my blocks in my layout.html, wouldn't it be "better" to have: {% block scripts %} <script src="/static/scripts.js"></script> {% endblock %} in the layout file and then just use: {% block scripts %}{{ super() }}{% endblock %} in the index html?
I am just not sure what the right convention would be in this case
2 Answers
Anthony Attard
43,915 PointsUsing {% block scripts %} <script src="/static/scripts.js"> {% endblock %} in the layout file and then using {% block scripts %}{{ super() }}{% endblock %} in the index html is a bad idea because it does not let you use a different script on another page. Doing it the way it's done in the video allows you to have different script files in each template.
matthias papsdorf
Courses Plus Student 4,152 PointsThank you for the explanation. For some reason I was too fixated on the aspect of having everything in the layout file. It did not think that far that other pages will require other scripts.
cheers, Matthias