Drupal Taxonomy vs Content Type Field

Drupal ships with an incredibly powerful and flexible categorisation system, called Taxonomy. However, many developers and site builders get confused when trying to decide if something should be a taxonomy term or a field in its own right.

There is not a hard and fast rule and people will give different advice. But as a general guidance, the following two questions should help in the decision making process:

1) Will the term/item/field be present on more then one content type?
2) If the term/item/field is removed, does the content type still make sense?

1) Will the term/item/field be present on more then one content type?

If the answer to the first question is yes, then in most cases I would recommend using Taxonomy.
An example might be a food website with one content type being recipes and another being cooking tips. If both content types require a field called cuisine, which indicates the country or culture that the food is from (eg Italian cuisine), then cuisine should be a taxonomy. If a user is looking at the term page for Italian cuisine, then that user will see both recipes and cooking tips that have been tagged with "Italian cuisine". Similarly you could create a view page with both content types as filters to show related cuisine information.

2) If the term/item/field is removed, does the content type still make sense?

If the answer to the second question is yes, then again I would recommend using Taxonomy. But it is not as clear cut as the first question. If the field can be removed and the content type still makes sense, then there is a good chance that in the future, another content type could be added with the same term/item/field. At that point in time you will ask yourself the first question, so by using taxonomy from the start, you will save yourself some time and effort in moving field data to a taxonomy.

This is a pretty straight forward and simplified way of looking at the question of taxonomy vs content type field, but hopefully it will be of some help.

If you liked this, you'll love my book, Master Drupal Module Development.

"..the must have drupal developers book"


Feeling stuck with Drupal 8 module dev?

Get the free 7 lesson course that will help you get started today without feeling overwhelmed.

  • Create Drupal modules with just a few commands using the Drupal Console
  • Create custom pages
  • Create custom blocks
  • Create admin forms
  • Demystify routers and controllers
  • Bonus material

Find out more


Comments

This is one of those questions that plagues new and not-so-new Drupalists. Here are two excellent articles that have earned a prized spot in my Evernote Drupal notebook. Dating from last year, they include custom entities as a third option.

http://www.4sitestudios.com/blog/sep-13-2013/when-use-content-types-taxo...
http://www.4sitestudios.com/blog/oct-08-2013/8-pitfalls-avoid-when-devel...

Thanks a lot for your explanation. It is really easy to understand.

Add new comment