Add tag "all" to Pelican

16 views Asked by At

I created the "project browser" (my articles are "projects"). I link the tags at the top and add the links to the projects below. But I would like to add the "ALL" tag, to list all the articles. But I am not sure how to do it.

My browser.html:

<h1>Tags for {{ SITENAME }}</h1>
<ul>
    <li><a href="{{ SITEURL }}/projects/all">ALL</a> ({{ articles|count }})</li>
    {% for tag, articles in tags|sort %}
        <li><a href="{{ SITEURL }}/projects/{{ tag }}">{{ tag }}</a> ({{ articles|count }})</li>
    {% endfor %}
</ul>

tags.html

{% extends "base.html" %}


{% block content %}
    {% include "browser.html" %}
{% endblock %}

tag.html

{% extends "base.html" %}

{% block content %}
    {% include "browser.html" %}

    <h2>Projects tagged with "{{ tag }}"</h2>
    <ul>
        {% if tag == "ALL" %}
            {% for article in articles %}
                <li><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
            {% endfor %}
            {% for article in articles if tag in article.tags %}
                <li><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li>
            {% endfor %}
        {% endif %}
    </ul>
{% endblock %}

The problem is that when I click on the ALL tag in the tags list it redirects me to a "/tag/all" page and such page doesn't exist (I understand that Pelican doesn't generate it as the "ALL" tag is not really on the list)? I have tried to add "ALL" tag automatically to all articles:

DEFAULT_METADATA = {
    'tags': ['ALL'],
}

but it still doesn't show on my tags list.

I know I could add the "ALL" tag manually to all the articles, but is there a smarter way?

0

There are 0 answers