title: Jekyll pagination with data files
body: <p>I was looking to try to do pagination with the _data files. Here is the code that I was coming up with but it doesn't work. Trying to make it work for a project I am working on right now for a nonprofit client I have.</p>
  <pre><code>{% if page.layout == &quot;events&quot; %}
      {% for events in paginator.events %}
      &lt;div class=&quot;card card-posts&quot;&gt;
          &lt;img src=&quot;{{ events.image }}&quot; class=&quot;card-img-top&quot; alt=&quot;...&quot;&gt;
          &lt;div class=&quot;card-body&quot;&gt;
  
              &lt;h1 class=&quot;card-title my-3&quot;&gt;{{ events.title }}&lt;/h1&gt;
  
              &lt;div class=&quot;meta-info&quot;&gt;
                  &lt;ul class=&quot;list-inline&quot;&gt;
                      {% if events.start %}
                      &lt;li class=&quot;list-inline-item&quot;&gt;
                          &lt;i class=&quot;fas fa-calendar-alt&quot;&gt;&lt;/i&gt; {{ events.start | date_to_long_string }}
                      &lt;/li&gt;
                      {% endif %}
                  &lt;/ul&gt;
              &lt;/div&gt;
  
              &lt;p class=&quot;card-text&quot;&gt;{{ events.summary }}&lt;/p&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
      {% endfor %}
  
  
      {% if paginator.total_pages &gt; 1 %}
      &lt;!--pagination--&gt;   
      &lt;div class=&quot;pagination bot-element&quot;&gt;
          &lt;div class=&quot;pr-bg pr-bg-white&quot;&gt;&lt;/div&gt;
          &lt;div class=&quot;container&quot;&gt;
              {% if paginator.previous_page %}
              &lt;a href=&quot;{{ paginator.previous_page_path | prepend: site.baseurl }}&quot; class=&quot;text-link&quot;&gt;&lt;i class=&quot;fal fa-long-arrow-left&quot;&gt;&lt;/i&gt;&lt;/a&gt;
              {% endif %}
              {% if paginator.page_trail %}
                  {% for trail in paginator.page_trail %}
                  &lt;a href=&quot;{{ trail.path | prepend: site.baseurl }}&quot; {% if page.url == trail.path %}class=&quot;current-page&quot;{% endif %} title=&quot;{{ trail.title }}&quot;&gt;{{ trail.num }}&lt;/a&gt;
                  {% endfor %}
              {% endif %}
              {% if paginator.next_page %}
              &lt;a href=&quot;{{ paginator.next_page_path | prepend: site.baseurl }}&quot; class=&quot;text-link&quot;&gt;&lt;i class=&quot;fal fa-long-arrow-right&quot;&gt;&lt;/i&gt;&lt;/a&gt;
              {% endif %}
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;!--pagination end--&gt;
      {% endif %}
  {% endif %}
  </code></pre>
  <p>Can someone see if this is a way possible that might have done this? If it is would it be ideal to do it for an events page to show an archive of events or no?</p>