In this video you’ll learn how to categorize content using the taxonomy system in Drupal.
We’ll cover the following:
- How to manage terms and vocabularies
- How to tag content
- How to edit term names
- How to access the term index page.
The taxonomy system in Drupal is used to categorise content. The word taxonomy means the science of classification and categorization. The taxonomy system offers an interface for managing vocabularies, which you can think of as category types, and you can create these categories from this page by clicking on the add vocabulary button.
And the system also has an interface to manage the taxonomy terms, which are the category items within the vocabulary and you can manage these terms by clicking on list terms. But this vocabulary doesn’t have any terms but once some are created, you can manage them from here.
And I should also mention that there is a module called taxonomy, which ships with Drupal core and it’s installed when you use the standard installation profile. So chances are, you have the module already installed.
Let’s now see the taxonomy system in action. When you install Drupal using the standard installation profile, it’ll create a vocabulary called tags, which you can see right here. It’s used to tag article content, and if we go to content, and I’ll open that up in a new tab, and then click on add content and then article, you’ll see that there’s a field called tags on the article content type. All of this is created if you installed Drupal using the standard installation profile.
Let’s go ahead now and create an article. I’ll enter in some text into the title field, and then paste in some random bit of text into body. And to tag this article, all you need to do is add a tag into this tags field. So I’ll go ahead and enter in tag one. And then if I want to add in a second tag, I will add in a comma and then add in tag two.
If the tag doesn’t exist, Drupal will automatically create it because if we jump back to the previous tab and then go to list terms on the tags of vocabulary, you can see that there are no tags available. But once we create the article, the two tags will appear here.
So let’s jump back to the create article form. Scroll down and click on save. And then here below body, you can see the two tags: tag one and tag two. And if we jump back to the previous tab and refresh, we should see our two tags: tag one and tag two.
To access the index page, just click on the term name and it’ll take you to a page with the path of taxonomy/term/ then the term ID. This page will display all of the tagged content. You can even access this index page from the article page. So let’s go back to our article and then just click on one of the tags.
From this list page, you can change the name of a term by clicking on edit and then changing the value in the name field. So let’s go ahead and change this from tag one to tag 10, and then click on save and straight away you can see that the name has been changed. And then if we go back to our article and refresh, you’ll see that now our tag one has become tag 10.
Content pages are referencing these terms by its term ID and not the name. This is why we can change the term name at any time, even if content has been created.