title: How to extract a method from Django HTML?
body: <p>My website (built with django) has pagination to not have to load too much content at once. The buttons to jump between the pages should always look the same. I found the following code on the internet which works great:</p>
  <pre><code>{% if is_paginated %}
      {% if page_obj.has_previous %}
          &lt;a class=&quot;btn btn-outline-info mb-4&quot; href=&quot;?page=1&quot;&gt;First&lt;/a&gt;
          &lt;a class=&quot;btn btn-outline-info mb-4&quot; href=&quot;?page={{ page_obj.previous_page_number }}&quot;&gt;Previous&lt;/a&gt;
      {% endif %}
  
      {% if page_obj.has_next %}
          &lt;a class=&quot;btn btn-outline-info mb-4&quot; href=&quot;?page={{ page_obj.next_page_number }}&quot;&gt;Next&lt;/a&gt;
          &lt;a class=&quot;btn btn-outline-info mb-4&quot; href=&quot;?page={{ page_obj.paginator.num_pages }}&quot;&gt;Last&lt;/a&gt;
      {% endif %}
  {% endif %}
  </code></pre>
  <p>Unfortunately I have to put this in each of my HTML files and have <strong>duplicated code</strong>. Is there a way to <strong>extract</strong> these few lines somewhere else and then only <strong>link to them</strong> in the respective HTML files?</p>