That works now, but I can’t figure out how to limit it to X posts. It grabs every single one, and I don’t think I can use paginate_by
to limit it? I tried {% if loop.index > 5 %}
inside {% for page in recent_changes.pages %}
but no luck.
Edit: I should have been using <
(less-than), not >
(greater-than). {% if loop.index < 5 %}
does what I want!
Based on the stuff above I figured out how to create an archive though! For anyone in the future looking to do the same thing, here’s what I did.
archive.html:
{% extends "base.html" %}
{% block title %}{{ section.title }}{% endblock title %}
{% block content %}
<h2>News Archive</h2>
<ul>
{% set recent_changes = get_section(path="news/_index.md") %}
{% for page in recent_changes.pages %}
{% if page.date and not page.template %}
<li>
{{page.date}} - <a href="{{ page.permalink | safe }}">{{ page.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endblock content %}
content/news/archive/_index.md
:
+++
title = "News Archive"
template = "archive.html"
+++