How do i select all tags in my twig template in grav?

have the following code in my default.html.twig file to display all the titles of the blog pages with the tag : dog:

<ul>
        {% for post in taxonomy.findTaxonomy({'tag':'dog'}) %}
        <li>{{ post.title }}<span>(0)</span></li>
        {% endfor %}
    </ul>

What i would really like to do is find all the tags and not just the dog tag, so i did the following:

<ul>
        {% for post in taxonomy.findTaxonomy({'tag':'all'}) %}
        <li>{{ post.title }}<span>(0)</span></li>
        {% endfor %}
    </ul>

I changed the dog to all , but this does’t really give me any results. I checked the documentation here for findTaxonomy , but it does’t help much , also in the inside the

  • , I would like to show how many articles for this perticular tag have been posted , eg. if there are five articles for the tag popcorn the html spitedd out should be:
  • popcorn (5)
  • . How do i achieve this ?

    what about not using taxonomy but a generic collection something like:

    {% for post in page.collection( items: {'@page.descendants': '/blog'} ) %}
    

    Some blogs have a collection defined in header, if that your case:

    {% for post in page.find('/blog-path').collection() %}
    

    https://learn.getgrav.org/content/collections

    For your other question, to show the number of posts, just get the page collection lenght something like:

    {{ page.find('/blog-path').collection()|length }}
    

    or

    <span>( {{taxonomy.findTaxonomy({'tag':'dog'})|length }} )</span>
    

    https://twig.symfony.com/doc/2.x/filters/length.html

    You can play with all that, if you can hardcode your tags that may work. but if you need a more dynamic code, you will need to check how this plugin is made:

    1 Like

    Thanks for that @hugoaf , what exactly is \blog-path here though ? is it something set in the header of the main blog page ? can you show me an example of how blog-path would look ?

    `page.find('path/to-page')`
    

    wil find the page:

    `your-website.com/path/to-page`
    1 Like

    Don’t want to necro but the actual solution is :

    <ul>
    {% for animal in taxonomy.getTaxonomyItemKeys('tag') %}
        <li>{{ animal }}</li>
    {% endfor %}
    </ul>