Terms, Vocabularies, and Taxonomy: "Tagging" Your Content
Words about words
Tags are power
Drupal offers a very flexible system for "tagging" your content – that is, attaching keywords to it for use in organization or searching. Why do that? As software developers and webmasters everywhere know, tagging content makes it so much easier for software to know what content is about. With tags on content, a program can instantly pick out, for example, all news articles that are about politics, or all product catalog listings that are cooking-related and are books (i.e., not just any cooking tools or any books, but only cookbooks).
Drupal can do the same with tagged content on your site. It's a very powerful tool that makes many things possible – so powerful and flexible, in fact, that the possibilities are overwhelming at first. This page outlines basic ways you can make use of tagging to organize your site content.
A word about words about words
First, a word about terminology. Let's revisit the discussion of "Taxonomy" from Important Terminology!:
Drupal lets you assign keywords, or "Terms", to your nodes. The language it uses to discuss this, however, can be a tad confusing. Here's your guide:
- Taxonomy: This is the overall name for the system Drupal offers to classify and organize nodes in your site by assigning them tags (called Terms; see below). You don't have to use Drupal's Taxonomy features to organize content, but it's usually extremely useful to do so.
- Term: A Term is a keyword or tag that you can associate with a node. Useful Terms include words like "news", "product", "pets", anything you can think of that classifies your content. With Terms to classify your content, you can easily organize it. For example, you can create a menu item called "News from the Pet World", which is set up to display any nodes that have the Terms "news" and "pets" attached – i.e., the articles you've written about pet-related news.
- Vocabulary: A Vocabulary is a number of Terms grouped together for convenience. For example, you might have a Vocabulary called "Product Type", containing Terms like "sweater", "jacket", "socks", etc., for use with any node that describes a product.
- Category: This is a confusing word: some Drupal documents say it means the same thing as Taxonomy, others seem to equate it with Vocabulary. Fortunately, it seems to be dropping out of use, and you may never come across it. This text will avoid it and stick to the words that Drupal is clear on: the "Terms" that act as tags for your nodes, and the "Vocabularies" that are groups of Terms. (But just to keep things complicated: to set and edit your Terms and Vocabularies in Drupal 5, you need to visit a form titled "Categories". Drupal 6 more sensibly labels this form "Taxonomy".)
Here's a short summary that puts those words into their places:
We're going to discuss Taxonomy, the use of "keywords" or "tags" to classify and organize your content. Instead of those popular words, though, Drupal calls keywords or tags Terms. It calls a group of related Terms a Vocabulary. So we'll talk mostly about Terms and Vocabularies. (We'll avoid Drupal 5's superfluous word categories.)
Got that? Good!
Ready-made tags: node types
Let's note from the start that all your content already has a built-in tag of sorts: its node type – Page, Story, Blog entry, etc. (I'm calling this "tag", not "Term", because Drupal doesn't technically treat node type as a Term.)
So even if you stop reading here and create or use no Terms, you're already classifying content in at least one way, and can organize it based on node type. For many sites, that simple organizational ability will be enough. Just use Blog entries for, say, news; Stories for product info; Pages for company info; and so on. Set a 'news' menu item to call up all Blog entries, a 'products' menu item to call up all Stories, and so on. There you go: simple organization for a simple site. See Creating Links for more.
A site of even moderate size or complexity, though, will quickly outgrow that scheme. If you'd like to explore a deeper way to organize content, read on.
Setting the Terms
Here's where to find our form for playing with Terms:
Navigation » Administer » Content management » Taxonomy
(In Drupal 5, that last part is "Categories", not "Taxonomy".)
The 'List' tab
The list you see under this tab is a list of Vocabularies. The three columns in the list:
The name of the Vocabulary.
This isn't a "type" of Vocabulary itself. Rather, this displays the node types that can use each Vocabulary.
For example, if you have a Vocabulary which you've named "topic", and this Vocabulary happens to list "Page, Story" under 'type', then that means only Page and Story node types can be tagged with Terms from the Vocabulary named "topic". Others, such as Blog Entry nodes, can not use the Terms from "topic".
Things you can do with the listed Vocabulary. See details below.
The 'Add vocabulary' tab
Before you can create and use Terms, you need to create one or more Vocabularies to hold them. If that's not already done for you on your site, read on. Here's what you see on the 'Add vocabulary' form:
The name of the Vocabulary. It will appear on the list of Vocabularies, and on forms for creating content (for any content types that can use the Vocabulary).
Description, Help text
Optional extra information. 'Help text' can be useful for telling users how you want them to use the Vocabulary, but otherwise, you can feel free to ignore these items.
As discussed above, you decide what node types can use this Vocabulary. This is where you decide, by checking the boxes of the node types.
For example, if you are creating a Vocabulary called "Product Category", and know that you only want to use its Terms with Page nodes (the node type you plan to use for your product info listings), you should check only 'Page'.
If unsure, check everything! If you're the only one entering content, there should be no harm. But if you're allowing others to create content on your site, put a little thought into it. For example, you may be allowing others to post Blog Entries on your site. Do you want to allow them to tag their entries with Terms from your "Product Category" Vocabulary, or not? This is the time to decide.
Settings (Drupal 6)
Here's a handful of options to customize how your Vocabulary works. (If you're using Drupal 5, see Hierarchy (Drupal 5) below.)
Tags: This option would be better named "Free tagging", not simply "Tags". It lets you freely tag content with whatever Term(s) you like, instead of choosing from a ready-made list. With this option enabled, you create a new Term, or use an existing one, by simply typing it into the text field Drupal provides. (You can enter multiple Terms by separating them with commas.)
This on-the-fly input is a good choice for content that requires an unpredictable or growing set of Terms. One example: You're creating a site that posts celebrity gossip. You'd like to tag each node with the discussed celebrities' names, but there are far too many to include in a list (and they keep breeding, too). On-the-fly Terms may be the perfect solution.
Multiple select: Another useful option. A node can always take a Term from each of separate available Vocabularies, but checking this option allows a node to use multiple Terms from the same Vocabulary. For example, say a single Vocabulary contains Terms that include "machinery" and "books". With the multiple select option enabled, a product listing for a machine repair manual could be tagged with both "machinery" and "books" from that Vocabulary. The result: A page that listed products tagged with "machinery", and a page that listed products tagged with "books", would each display this particular product.
If you're using free tagging (the "Tags" option above), you automatically have the ability to tag content with multiple Terms from this Vocabulary, and can ignore "Multiple select".
Note: When you create a node and choose multiple Terms from a Vocabulary, selecting the second Term will only un-select the first. You need to hold down your computer's "mutiple select" key (Command for Macs, Ctrl for Windows machines) when making the second and later selectons.
Required: You're normally free to tag a piece of content with no Term from a given Vocabulary. But not if this setting is checked! You won't be able to submit the node without selecting a Term (or inputting one if using free tagging). This is a useful setting when you are allowing others to submit content, and want to enforce tagging.
There are several choices under this heading (not all of which are really connected to hierarchy):
Disabled, Single, or Multiple: Just as menu items can have "child" sub-menus, your Terms can have "child" sub-Terms below them.
If you select 'Disabled', that won't be the case for this Vocabulary; it will have one "flat" level of Terms beneath it.
If you select 'Single', you can have child Terms, even in multiple layers. For example, your "Product Category" Vocabulary may have the Terms "tools" and "machinery" – and under "machinery", more specific child Terms like "pump", "generator", and "purifier".
More layers are possible. Your child Term "purifier" might have "filtration", "reverse osmosis", and other purifier types below it, as "grandchild" Terms.
If you select 'Multiple', a child Term can appear under more than one parent Terms. For example, you could have the Term "lathe" appear as a child under "tools", and appear as a child under "machinery". Just select as many parents as you like when creating the Term (for the second and later Terms, use your computer's "mutiple select" key: Command for Macs, Ctrl for Windows machines).
With multiple parent Terms selected, the new child Term will appear separately under each parent. It's still a single "instance" of the Term, though; if you pick one of the Term's appearances for modification or deletion, you'll modify or delete all its appearances in that Vocabulary.
What's the point of these hierarchies? In addition to general orderliness in your Vocabulary, you can make use of useful techniques, such as a single link that returns all content tagged with the parent Term and its child Terms. For example, you can create a link returning content tagged with machinery", or any of "pump", "generator", and the other child Terms below it. That link will catch any nodes dealing with machinery products, even a node only has the Term "pump" and not "machinery". See Creating Links.
Free tagging: This is the same as Tags under Settings (Drupal 6) above.
Multiple select: This is the same as Multiple select under Settings (Drupal 6) above.
Required: This is the same as Required under Settings (Drupal 6) above.
This will determine the placement of the Vocabulary on the list of Vocabularies – a matter of very little importance. Feel free to ignore it.
Editing a Vocabulary
Clicking 'edit vocabulary' on the list of Vocabularies takes you to this form. It's the same as the form for adding a Vocabulary; see full procedures above.
At long last, we get to the meat of your Vocabularies: the Terms contained within. Clicking 'list terms' on the list of Vocabularies shows you two things: a list of the included Terms, and a link to add more Terms (see below).
The list of Terms has two columns, 'Names' and 'Operations'. The latter only holds a link to edit the Term. The former is more useful than it first looks: each Term's name in the list contains a link that calls up all content tagged with that Term. This will come in handy when making menu items and other links that call up content based on Terms. See Content Paths and URLs and Creating Links.
The final item to cover, and an important one, is the tool to create new Terms.
Clicking 'Add term' switches to an 'Add term' tab. Here's what it offers:
The name of the Term: "products", "news", "general info", "France", whatever you want.
Type in some info on the Term, or its intended use, if you wish. It's generally not important.
Here you have the option of creating a "hierarchy" of Terms, by placing a new Term under a "parent" Term (assuming there's already at least one Term in the Vocabulary). Pick '<root>' to place the Term at the "top level", with no parent Term. Or pick an existing Term to place your new Term under it as a child Term.
Under Drupal 5, you have to first enable the ability to create this hierarchy. See Disabled, Single, or Multiple under Hierarchy (Drupal 5) above.
The usefulness of this feature isn't yet clear. Ignore.
The usefulness of this field isn't yet clear. Ignore.
If it matters to you, you can use "weight" to set the Term's location inside the Vocabulary. A "light" (negative) weight will place it higher on the list; a "heavy" (positive) weight will place it lower. Many admins won't consider this important.
Now that you've got Terms, what to do with them? Simple: when you create content, you'll see Terms listed under 'Vocabularies' ('Categories' in Drupal 5) on the node's edit form. Each available Vocabulary will appear as a separate list (or as a text input field if the Vocabulary uses free tagging). From each Vocabulary, pick whatever tags you want to attach to that node (or input tags if the Vocabulary uses free tagging). This is briefly described under the heading Vocabularies ("Categories" in Drupal 5) on Create a Page Node.