I’ve been developing a flask application and have come across a very strange problem. My Bootstrap JS script is apparently not working on one specific pages where the footer block isn’t included. I’ve looked around and tried many things and the only thing that makes it work is if I include the footer on that specific page. Keep in mind the footer does not have any scripts at all in it.
My base.html:
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{% block title %}{% endblock %}</title>
{% block styles %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
<link
href="{{ url_for('static', filename='css/styles.css')}}"
rel="stylesheet"
/>
<link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Libre+Baskerville&family=Raleway:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
{{ bootstrap.load_css() }}
{% endblock %}
</head>
<body>
{% block header %} {% endblock %}
{% block content %} {% endblock %}
{% block footer %} {% endblock %}
{% block scripts %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js?v=5.3.3"></script>
<!-- Custom JS -->
<script src="{{ url_for('static', filename='js/custom_javascript.js') }}"></script>
{% endblock %}
</body>
</html>`
Footer:
{% extends "base.html" %}
{% block footer %}
<footer class="py-3 my-4 container footer-container">
<div class="row row-cols-1 row-cols-sm-3 align-items-center text-center text-sm-start">
<div class="col mb-3 mb-sm-0 d-flex justify-content-center justify-content-sm-start">
<p class="mb-0 text-body-secondary" style="color: #E8E8E8 !important;">© 2025 Stefan Krsmanović</p>
</div>
<div class="col mb-3 mb-sm-0 d-flex justify-content-center">
<img src="{{ url_for('static', filename='assets/img/rep_talk_logo.png') }}"
alt="Logo" width="32" height="32"
class="d-inline-block align-text-top">
</div>
<div class="col d-flex justify-content-center justify-content-sm-end">
<ul class="nav flex-column flex-sm-row align-items-center">
<li class="nav-item">
<a href="{{ url_for('home') }}" class="nav-link px-2 text-body-secondary custom-link">Home</a>
</li>
<li class="nav-item">
<a href="{{ url_for('website_features') }}" class="nav-link px-2 text-body-secondary custom-link">Website Features</a>
</li>
<li class="nav-item">
<a href="{{ url_for('home') }}" class="nav-link px-2 text-body-secondary custom-link">About Me</a>
</li>
</ul>
</div>
</div>
</footer>
{% endblock %}
Page where this isn’t working:
{% extends "base.html" %}
{% block title %}Profile{% endblock %}
{% block header %} {% include "header.html" %} {% endblock %}
{% block content %}
<div class="container mt-4" style="max-width: 720px;">
/* Page Content Here */
</div>
{% endblock %}
I tried this in the console on the problematic page:
new bootstrap.Alert(document.createElement(‘div’))
And it gives me no error, also no other errors in the console. Does anyone have any idea what this can be?
I tried including different bootstrap links, checking the console, including scripts in the problematic file itself. If I included scripts in the header file then it would work, but would cause it to not work on other pages for some reason.