Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Taxonomy in Drupal

What is Taxonomy?

Taxonomy is a system of classification. In the context of Drupal, it refers to the way content is categorized and organized. Taxonomy allows you to create, manage, and assign categories, tags, and other vocabulary terms to your content. This helps in organizing content in a meaningful way, making it easier for users to find relevant information.

Understanding Vocabulary

In Drupal, a vocabulary is a collection of terms. Each vocabulary can contain multiple terms, which can be used to categorize content. For example, you could have a vocabulary called "Topics" that includes terms like "Technology", "Health", and "Science".

Example Vocabulary:
  • Vocabulary Name: Topics
  • Terms:
    • Technology
    • Health
    • Science

Creating a Vocabulary

To create a vocabulary in Drupal, follow these steps:

  1. Navigate to Structure > Taxonomy.
  2. Click on Add vocabulary.
  3. Enter a name for your vocabulary (e.g., "Topics").
  4. Click Save.
Command:
Go to Structure > Taxonomy > Add vocabulary

Adding Terms to a Vocabulary

Once you have created a vocabulary, you can add terms to it. Here’s how:

  1. Navigate to your vocabulary (e.g., "Topics").
  2. Click on Add term.
  3. Enter the name of the term (e.g., "Technology").
  4. Click Save.
Command:
Go to Topics > Add term

Using Taxonomy in Content Types

Taxonomy terms can be assigned to content types to categorize your content. To do this:

  1. Navigate to Structure > Content types.
  2. Edit a content type (e.g., "Article").
  3. Under the Fields tab, click Add field.
  4. Select Term reference as the field type.
  5. Choose the vocabulary you want to associate (e.g., "Topics").
  6. Click Save.
Command:
Go to Content types > Article > Fields > Add field

Displaying Taxonomy Terms

You can display taxonomy terms on your site using views or by modifying your content type display settings. This allows users to see related content based on the taxonomy terms.

Example of Displaying Terms:

Using Views, you can create a block that lists all articles tagged with the "Technology" term.

Conclusion

Taxonomy is an essential feature in Drupal that provides a powerful way to organize and categorize content. By creating vocabularies and terms, you can enhance the navigability of your website and improve user experience.