CERN Accelerating science

Close menu

Taxonomy

Taxonomy consists one of the most important Drupal elements, as it gives the ability to the admins to label their content. In this way the content is categorized and becomes organised and easily accessible throughout the website.

The taxonomies are terms which are grouped into vocabularies. Every Taxonomy term belongs to a vocabulary which characterizes semantically its origin. For instance, in the “Entities Classification” article of “How to Plan” section, we provided an example of a booking website where each hotel can be tagged with its category . If we wanted to implement this website using Drupal CMS, we would create a “Hotel Category” vocabulary and within this vocabulary we would create 3 taxonomy terms: Hotel, Hostel and Aparthotel.

Another important characteristic of taxonomy vocabularies is the support of fields. Taxonomy Vocabularies are able to encapsulate a set of defined by the admin fields and this way you can store field values which can consequently be used by the content which is tagged with this taxonomy term. The concept of fields encapsulation in taxonomy terms can be proved really useful especially in complex content structures.

How to create taxonomy vocabulary

The taxonomy workspace of your website is located in Structure -> Taxonomy

Vocabulary

The process required in order to create a taxonomy vocabulary and terms is the following:

  1. From the taxonomy workspace click on “Add Vocabulary”
  2. Fill the fields of your vocabulary. The fields are straightforward and clear.Vocabulary settings
  3. After Saving the vocabulary form, you are redirected to the terms page of the created vocabulary.

How to create taxonomy terms for a vocabulary

For the following steps, we assume that you have already created a vocabulary as described in the previous section.

Having created a vocabulary you can then create terms for it by clicking on “List Terms” button of the vocabulary you want to edit and then “Add Term”. The following form will guide you to create the new term for the vocabulary by filling:

  1. Name: The name of the term
  2. Description: Text to make the term more understandable.
  3. Relations: You can create relations between terms of the same vocabulary. In this way, you can have parent and child terms to keep the terms more organised.
  4. URL alias: You can give a URL alias to mask the default URL of the term.
vocabulary description

How to tag content with taxonomy term(s)

As already mentioned in previous sections, taxonomy terms are used to tag the website’s content. Until now we showed how to create a content type, how to create content of a content type and how to create a taxonomy vocabulary. In order to tag content with a specific term or terms, the only thing you need to do is to map the content type with the vocabulary. This is simply done by creating a reference field in the content type to this vocabulary:

  1. Visit the fields page of the content type you want to tag.
  2. Click on “Add Field”.
  3. Select “Taxonomy Term” and give it a descriptive label.
  4. Choose whether you want to reference one or more taxonomy terms.taxonomy reference
  5. Provide a nice and descriptive help text, choose whether or not you want the field to be required and finally choose from which vocabularies to be able to choose.
taxonomy field

 

Related FAQs