title: How to repeat a block in a jinja2 template?
body: <p>I'm using <a href="http://jinja.pocoo.org/docs/" rel="noreferrer">Jinja2</a> as the template engine to a static HTML site generated through a Python script.</p>
  
  <p>I want to repeat the content of a block in the layout template, which goes something like this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;{% block title %}{% endblock %} - {{ sitename }}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;{% block title %}{% endblock %}&lt;/h1&gt;
      &lt;div id="content"&gt;
          {% block content %}{% endblock %}
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This template will be extended in a page template, that looks like this:</p>
  
  <pre><code>{% extends "layout.html" %}
  {% block title %}Page title{% endblock %}
  {% block content %}
  Here goes the content
  {% endblock %}
  </code></pre>
  
  <p>However, this doesn't work as I expected, resulting in an error:</p>
  
  <pre><code>jinja2.exceptions.TemplateAssertionError: block 'title' defined twice
  </code></pre>
  
  <p>Jinja interprets the second <code>{% block title %}</code> in <em>layout.html</em> as a block redefinition.</p>
  
  <p>How can I repeat the content of a block in the same template using jinja2?</p>