23.7 Taxonomy Weights: Ordering Terms

Right, so you’ve got your categories and tags all set up. You’ve dutifully sorted your content into beautiful, logical buckets. Now you want to slap them on your website’s sidebar in a “Popular Topics” list, and… they’re in alphabetical order. Alphabetical! The default setting for when you have no opinion. It’s the digital equivalent of shrugging and saying “I dunno, whatever.” For a list of “Popular Topics,” this is, to use the technical term, completely useless. You don’t want “Antiques” before “Zeppelins” just because the alphabet says so; you want the terms you’ve used the most—the heavy hitters—to appear first.

23.6 Disabling Taxonomies

Right, so you’ve built this beautiful taxonomy system. Categories for your broad sections, tags for the free-form chaos, maybe even a custom taxonomy for ‘Pizza Toppings’ because why not. But now, you’ve hit a point where you need to perform a bit of taxonomy-ectomy. Maybe the client decided ‘Tags’ are too 2009, or perhaps that custom ‘Manufacturer’ taxonomy you built is now being handled by a separate plugin that’s throwing a fit. Whatever the reason, you need to disable a taxonomy, not just hide it.

23.5 Displaying Related Content via Taxonomies

Right, so you’ve gone to all the trouble of meticulously categorizing your content. You’ve got your ‘Genre’ taxonomy for your movie reviews and your ‘Ingredients’ taxonomy for your recipes. Pat yourself on the back. But a taxonomy sitting alone in the admin panel is like a meticulously organized toolbox you never open. It’s useless. The real magic, the reason we bother with this whole taxonomy rigmarole, is to dynamically connect content for the person actually reading your site. Showing a user “Oh, you liked Die Hard? Here are five other 80s Action movies we’ve reviewed” is the entire point. Let’s get that magic on the screen.

23.4 Taxonomy Templates: List and Term Pages

Right, let’s talk about the pages WordPress generates for your taxonomies. You’ve defined these beautiful structures to organize your content, and now WordPress, like a well-meaning but slightly clumsy intern, has to figure out how to present them to the world. It does this with two types of pages: the list (the archive of all posts in a term) and the term page itself (which is often just a more specific archive). The system is powerful, but it has its… quirks. We’ll navigate them together.

23.3 Adding Taxonomy Values in Front Matter

Right, let’s talk about actually using these taxonomies we’ve so carefully set up. You don’t define a category system just to admire its architectural beauty. You need to populate it. And in the world of static sites, that almost always starts in the front matter. Think of front matter as the classified section of your content. It’s where you, the author, stick all the metadata—the behind-the-scenes info that tells the system what this thing is and how it should behave. Taxonomies are a huge part of that. You’re essentially slapping labels on your work so the automated sorting machine (Hugo) knows which bins to put it in.

23.2 Defining Custom Taxonomies in Configuration

Alright, let’s get our hands dirty. You’ve outgrown the default ‘category’ and ‘post_tag’. Good for you. They’re fine for a quick blog, but for a serious site—be it a portfolio, a product catalog, or a repository of weird mushroom facts—you need custom taxonomies. This is where you stop letting WordPress dictate your content structure and start building it yourself. Think of a taxonomy as a way to group things. ‘Category’ is a taxonomy. ‘Tag’ is a taxonomy. We’re just making new ones. The real magic trick here is that we’re going to define these in our theme’s functions.php file (or better yet, in a site-specific plugin) using the register_taxonomy() function. This function is your new best friend; it’s powerful, but a bit fussy about its arguments.

23.1 Built-in Taxonomies: tags and categories

Alright, let’s talk about the two taxonomies WordPress gives you out of the box: categories and tags. Don’t let their apparent simplicity fool you; this is where most people’s site organization goes to die a slow, confusing death. I’m here to make sure that doesn’t happen to you. Think of it this way: categories are your site’s table of contents, and tags are its index. Categories are meant for broad, hierarchical groupings—you know, the chapters of your book. “Recipes,” “Travel,” “Political Rants You’ll Regret Later.” Tags, on the other hand, are the specific, granular keywords—the index entries. For a recipe post, your category might be “Desserts” and your tags would be “chocolate,” “easy,” “no-bake,” “regret.”

— joke —

...