Is it possible to set query parameters via jinja in Pelican template files?
index.html
{% if articles %}
{% for article in articles_page.object_list if article.category == 'article' %}
#stuff
{% endfor %}
{% endif %}
This will return articles in the article category, but only if they happen to be in the articles already queried for. The desirable setup would be to grab x articles in y category (or with y tag) - is that possible?
This code snippet works for me to bring back a list of all articles matching a tag:
{% block content %}
<ul>
{% for article in articles if FAVORITES_TAG in article.tags %}
{% if loop.index <= FAVORITES_COUNT %}
<li><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endblock %}
I set the FAVORITES_TAG and FAVORITES_COUNT variables in the config. I hope that helps.
I ran into the same problem, and found a solution
{% if articles %}
{% for article in articles_page.object_list if article.category.name == 'article' %}
#stuff
{% endfor %}
{% endif %}
来源:https://stackoverflow.com/questions/19283880/querying-for-specific-articles-via-tag-category-in-pelican-themes