[Bug] Removing an independent tag with the same name as a parent tag removes children tags

I had a few notes tagged with “A” and with other tags (like “aa”, “ab”, etc.). I decided to nest them using the tag tree so I renamed the inferior tags (right click on tag in browser’s left panel and Rename) like this: aa> A::aa, ab > A::ab, ac > A::ac, etc.

After doing that the notes still have both tags, for example, one note has the tag “A” but also the tag “A::aa”. Now, I don’t need the tag “A”, since it is already included in “A::aa”. I go to Notes - Remove tags… in the browser, select to delete the “A” tag from the notes, and instead it deletes both “A” and “A::aa”.

I don’t think this is the intended behavior. Right now, the only way I have to remove the “A” tags from the notes without also deleting the “A:aa” is to manually click on the X in the tag section of the right panel one card at a time.

I am guessing this is a bug. In any case, is there a way to only remove “A”, whithout removing the “A” tree?



I agree that the current behavior is less than ideal.

For now, you should be able to work around that by using Find and Replace.
(Edit: I updated the post to include a slightly more robust method)

  • Find: name of the “parent tag” preceded by the ^ symbol and followed by the $ symbol
  • Replace With: leave empty
  • In: Tags
  • Selected notes only: yes/no depending on what you want to do
  • Ignore case: yes
  • Treat input as regular expression: yes

E.g. if you had these tags: Arts, Arts::Paintings, Arts::Sculpture and you wanted to remove Arts

If you had these tags: Arts::Paintings, Arts::Paintings::Impressionism, Arts::Paintings::Expressionism and you wanted to remove Arts::Paintings

I recommend creating a backup first!


Thanks! I had completely forgotten I could use search and replace with tags. In any case, I think the behavior should be improved.

I also noticed I had some cards with tags like “a_b” while already having “a”. I changed both to “c::a”. And now I have some notes with two identical tags “c::a”. And I don’t think search and replace can help me with that. :S

Ok, disregard the last part. I just rechecked and the note that was showing two identical tags now only shows one… No idea what happened (I didn’t even close the browser window).

I’m afraid I suspect the more common case is users wanting to delete a tag and its child tags at the same time.


Of course, I would too. The problem is that Anki shouldn’t duplicate tags. If I have Art::Paintings, Anki should not keep an independent “Art” tag, right? What would it’s purpose be if I already have a parent “Art::”?

Anki should detect and merge them. Or at least it should list “Art” and “Art::” separately in the left panel, so I can delete one without deleting the other.

1 Like

Changed the title so the problem is clearer.

From a user’s standpoint, it does not make much sense for Anki to keep both ‘ParentTag’ and ‘ParentTag::ChildTag’ on the same note.
At least, off the top of my head I can’t think of any use case that would benefit from this behavior. All it does is to add redundancy and take up space in the collection.

Ideally, Anki should automatically detect such instances and retain only the more nested version of the tag. Either immediately, or when using Clear Unused Tags and/or Check Database (in the hope that it would not be too computationally expensive).

1 Like

I’m not sure this is something Anki needs to solve - users can already avoid this by not adding parent tags to their cards.

A relatively frequent situation where this would be relevant is when users add multiple ‘simple’ tags, and later convert them into hierarchical tags.

E.g., a user may have some notes with these ‘simple’ tags: Geography, Mountains, Europe, and later decide to make Mountains a child of Geography ( → Geography::Mountains).
For example, by using the drag and drop function of the left bar of the Browser.

→ The notes would end up having these tags: Geography, Geography::Mountains, and the only way to fix this (that does not involve RegEx) is to delete both (using ‘Notes > Remove Tags’) and then add Geography::Mountains back.

If the user moves multiple ‘simple’ tags under the same parent tag (e.g. ending up with Geography, Geography::Europe, Geography::Mountains), fixing it easily becomes even more complex.

My reasoning was also that, by optimizing the tag structure, it could potentially lead to a reduction in the size of many users’ collections, resulting in decreased space usage on AnkiWeb (although admittedly I’m not sure what the entity of the gain would be).

That being said, I am not suggesting that Anki should implement this right here and now, (of course!), or even that it would be an enourmously important feature to adopt. Just that it seems to make sense, in theory, and that it would make a nice quality of life improvement.

1 Like

I’m not arguing it would have no utility, but given that you can either use find&replace to recover after the fact, or rename parent to parent::misc when you decide to change it from a leaf node to a branch, I’m afraid it’s not a high priority at the moment.

It can be avoided, but by giving the user more work when organizing their collection.

If a user has several tags they want to group under a shared parent tag, they would need to go one by one adding the “new” child to the parent. (And maybe then the previous independent tag would remain and need to be deleted, and those can be many tags to delete.)

It would be much more straight forward to just rename the child tags to Parent::Child, so that Anki reorganizes everything.

Or even better, just making so that removing the tag “Parent”, would only remove that, while removing “Parent::*” would remove that tag and its child tags.

Probably not the highest priority, sure. But I struggle to see how the current implementation has any benefit, and it can get confusing. Hopefully it will be dealt with at some point. :slight_smile:

1 Like

Just adding this post here in case it helps deciding if the problem should be tackled:

It is not possible (or I don’t know how) to search for a standalone tag if there is also a parent tag with the same name.

A solution would be to Find and replace the standalone tag and change its name. But I think this is a complicated route. Maybe there should be at least an easy way to search for these tags?

In the example of the post above, maybe searching for tag:Hyperskill could only offer results with only that tag, while tag:Hyperskill* or tag:Hyperskill:: offering results for all cards with that tag as a parent?


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.