Log in Sign up

Possible to filter tags from lists of tags

Trying to conceptualize how to set up my portfolio site and I was wondering if it's possible to return a more refined list of tags than either {{#all_tags}} or {{#popular_tags}}. Specifically, I'd love to be able to display a list of tags that are subhierarchical to a tag folder they reside in.

Using examples from the docs, let's imagine a site set up like:

[Pictures]›[Sicily]
[Pictures]›[Venezia]
[Essay]›[Roma]

And calling {{#all_tags}} {{tagged.Pictures}}... would return the tag links [Sicily] and [Venezia] (which could be used to generate categorical navigation links as in the nav of the portfolio theme which is the base of the fork).

Is there a different way to approach this or is a function similar to this possible?


2 years ago, 5 replies   Edit question

I really want to add this feature, I'm just not sure how to do it.

Perhaps when filtering one list of tags, we could produce a list of related tags, i.e. for the list of posts tagged pictures, we would surface Sicily and Venezia?

It wouldn't be a true hierarchy, though. Let's say you had:

[Pictures]›[Sicily]
[Pictures]›[Venezia]
[Pictures]›[Venezia]›[Ca' Pesaro]

When filtering by tag 'Pictures', would you want the related tags to contain Sicily and Venezia? Or would you be ok with Sicily, Venezia and Ca Pesaro?

Answered 2 years ago · Edit answer

I would be okay with Sicily, Venezia, and Ca' Pesaro appearing for my purposes though the more discriminatory filter may be useful for others. My use case is simply adding two blocks of links in distinct categories automatically to nav and the basic filtering would work perfectly for that.

Answered 2 years ago · Edit answer

I probably need to read more about data structures or graphs to accomplish this, but I wonder if it's possible to create the hierarchy you're after from what Blot knows right now, e.g.

first.jpg: Pictures, Sicily
second.jpg: Pictures, Venezia
third.jpg: Pictures, Venezia, Ca' Pesaro

To something like

Pictures  → Sicily
          → Venezia → Ca' Pesaro

Perhaps we could construct a tag hierarchy that basically says, if all posts tagged 'X' are also tagged 'Y', but not all posts tagged 'Y' are tagged 'X', we make tag 'X' a child of tag 'Y'.

The system would be brittle because you could create a markdown file elsewhere in your folder with an inline tag 'Venezia' and then break the whole thing... but maybe brittle is good enough?

Alternatively, I could just add a way to traverse a folder structure within a template, which might make this whole question much simpler, would likely be a useful feature in many other ways.

Answered 2 years ago · Edit answer

Any of those would work for my use as would simply extending the tag filter mechanism that already exists, ie {{#tagged.pictures}}, to the {{#all.tags}} listing functionality.

Answered 2 years ago · Edit answer

I see, I'll have a think about the 'interface' for this template tag

Answered 2 years ago · Edit answer