3

Seeing as there currently isn't a way of deleting / managing tags in Craft3, I was wondering if someone could point me to where in the database these tags are stored so I can delete them manually.

Thanks in advance :)


edit: Looks like tag management through the CMS is also on the agenda for version 3 as seen in this git issue.

https://github.com/craftcms/cms/issues/820

1

1 Answer 1

4

Tags are Elements and are stored in multiple places in the database, so editing the db directly may not be as easy as just finding the Tags you want and deleting them.

The tag itself is stored in multiple places including the tables:

content
elements
elements_sites
tags

You'll find the Tag Name that you recognize in the content table in the title column. However, the only way to delete the references to a given tag in all of the tables would be to delete it by it's Element ID in the elements table, which would cascade through the other tables and clean them up as well.

Quite possible to do via the db directly, but probably not advisable or convenient in many situations. Be sure to backup your database before you try, if you dare.


In the case this must be done manually, you could consider the following steps:

Export all tags from the db into a CSV file. Select all the ones you wish to delete. Use your spreadsheet to combine all the Element IDs of the tags you want to delete into a comma-delimited list. Then return to your database program and delete all the Tags by their Element IDs:

DELETE FROM elements
WHERE id IN (1, 3, 5, 7, 9);
2
  • Thanks for the response. I'll have a go at looking for them in these places after doing a back up :) I did see that tag management has been moved to the backlog for Craft 3x so hopefully it does get implemented.
    – JoelS
    May 18, 2018 at 1:08
  • 1
    As it sounds like you're going for it, I've updated the answer with a DELETE query that could come in handy. Maybe consider adding that ticket you found here in the comments so others who find this question could find and upvote it too. Good luck! May 18, 2018 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.