Is it possible to automatically set page icons based on tags?

Is there a way to automatically apply a predefined icon to a page when I add a tag to it in Logseq DB?

It seems that changing the icon of the tag page itself also affects the icons of pages tagged with it to some extent. However, the result is quite different from actually changing the icon of those pages.

Also, this approach makes it difficult to distinguish the tag page itself from other pages.

Is there a proper way to automatically assign a specific icon to pages based on their tags?

  • If I understand correctly, Logseq:
    • after checking whether a node has its icon defined explicitly,
      • in which case it displays that icon
    • it scans the node’s tags for those that have an icon defined
      • If multiple tags have icons, seems that the earliest-created tag “wins”.
  • Therefore:
    • If a tag has an icon defined,
      • if a node is tagged with that tag,
        • that icon is displayed for that node,
          • as long as:
            • there is no other tag that takes precedence
            • that node doesn’t have its icon defined explicitly (highest precedence)
    • Setting an icon on a tag, effectively (not actually) auto-assigns that icon to every node tagged with that tag.
      • As long as it doesn’t already have an icon of higher precedence.
      • That means that the user doesn’t have to set an icon explicitly for each one of those nodes.
  • It is not a perfect design.
    • But if you know its rules, it is possible to get the desired icons displayed.

I would like the icons to also be displayed in the recent pages list and in [[page links]].

When I manually set an icon for a page, it is displayed correctly in all of these places. However, when the icon is inherited automatically from a tag after setting an icon on the tag page, the icon is only displayed before the page title when the page itself is displayed in full.

I’m not sure whether this is intentional behavior by design or a bug.

Ah, I just realized that you were absolutely right.

page automatically has the #page tag, and since the icon for the #page tag takes priority, it only looks like the icon setting for the new tag isn’t being applied to pages. I didn’t realize this because the #page tag isn’t explicitly shown.

Hmm, technically this makes perfect sense, but I’m not entirely satisfied with it. I think the icon priority for #page should be lowered, at least when it comes to pages.


[Update] This was just a bug, and it has been fixed: Tag icons not inherited in block references to pages · Issue #1082 · logseq/db-test · GitHub