Title being displayed both in browser's bar and in body in Django

Viewed 118

I am following the book "Django By Example" and I tried to implement tags. I expect the title to be shown only on the browser's title bar. However, the text inside is being displayed both on the browser's title bar but also on the webpage content. enter image description here

If I look at the page source, of that screenshot, it looks like this:

    </nav>
    

            
 Title goes here 

<div class="container">

And here is how the first lines of my base.html look like:

{% load static %}

<!DOCTYPE html>
<html>
  <head>
    <title>{% block title %} {% endblock %}</title>

And here is the template of the page shown in the screenshot:

    {% extends 'base.html' %} {% block content %}
    {% block title %} Title goes here {% endblock %}
    
    <div class="container">
      <div class="row">
    
        <div class="col-md-8 card mb-4  mt-2 left  top">
          <div class="card-body">
            <div class="">
              Here is some content.
          </div>
            </div>
        </div>
        {% block sidebar %} {% include 'sidebar.html' %} {% endblock sidebar %}
      </div>
    </div>

{% endblock content %}

Do you know how to get rid of the tile being displayed on the page body?

1 Answers

The fact your block title is also in the block content might be the reason, just put it outside.

{% extends 'base.html' %} 

{% block title %} 
    Title goes here 
{% endblock %}

{% block content %}
    <div class="container">
      <div class="row">
    
        <div class="col-md-8 card mb-4  mt-2 left  top">
          <div class="card-body">
            <div class="">
              Here is some content.
          </div>
            </div>
        </div>
        {% block sidebar %} {% include 'sidebar.html' %} {% endblock sidebar %}
      </div>
    </div>
{% endblock content %}
Related