6.8 The Page Object: Accessing Every Field in Templates

Right, let’s talk about the Page object. It’s the single most important variable in your Hugo templates, the key to the kingdom, the master switchboard. When you see .Site or .Title in a template, you’re tapping into this object. It’s Hugo’s way of taking all the disparate data you’ve slung into YAML, TOML, or JSON front matter and squashing it into one beautifully convenient, if occasionally quirky, Go structure for you to play with.

6.7 Cascade: Inheriting Front Matter Down a Section Tree

Right, so you’ve got your site structured into sections. Maybe you have a posts/ directory and a projects/ directory. You’ve painstakingly set the author and layout in the front matter of every single file. It works, but it feels… repetitive. And you’re right, it is. We’re programmers. We hate repetition. This is where Hugo’s front matter cascade comes in, a feature so powerful it feels like you’re getting away with something. The core idea is simple: you can define default values for front matter in your content directory structure itself, and those values will cascade down through that section of your content tree. It’s inheritance, but for your metadata.

6.6 Custom Params: Arbitrary Key-Value Pairs for Templates

Now, let’s talk about the secret sauce, the duct tape, and the junk drawer of your Hugo site: Custom Params. This is where you get to attach your own arbitrary key-value data to pretty much anything—your site, your sections, and most importantly, your content pages. It’s the mechanism that lets you move beyond the standard front matter fields and build truly dynamic templates. The concept is brilliantly simple. In your front matter, under a top-level key called params, you can define any custom data you want. Hugo doesn’t care what you put in there; it just collects it all and makes it available for you in your templates. It’s your personal storage locker for template variables.

6.5 Layout and Type Fields: type, layout

Alright, let’s get our hands dirty. Before you can build anything, you need to tell Cargo what you’re building. Is it a library? A binary? A terrifyingly complex workspace with a dozen sub-crates? This is where type and layout come in, and they are the bedrock of your Cargo.toml. Get these wrong, and nothing works. Get them right, and you’ve laid a solid foundation. The package.type Field: What Are You, Anyway? The type field, specified under the [package] table, is the single most important piece of information you’ll declare. It tells the Rust compiler and Cargo the fundamental nature of your project’s output. Forget this, and Cargo will make an assumption—an assumption you probably won’t like.

6.4 Ordering Fields: weight, lastmod, publishDate, expiryDate

Right, let’s talk about order. Your content is a pile of brilliant ideas, and by default, Hugo will list them in a way that makes sense only to a computer (alphabetical by filename, if you’re curious). We’re not computers. We want to control the narrative. Hugo gives you a delightful little toolbox of front matter fields to impose your will upon this chaos. Let’s break them down, from the most blunt instrument to the most nuanced.

6.3 Taxonomy Fields: tags, categories, and Custom Taxonomies

Alright, let’s talk taxonomy. You’re going to be using these. A lot. The whole point of a CMS like Hugo is to structure your content so you can, you know, find it again. Taxonomies are your primary tool for that. They’re the index cards for your digital library, and if you do them right, you can find anything in seconds. Do them wrong, and you’re just piling metadata in a corner for the digital mice to nibble on.

6.2 Core Fields: title, date, draft, description, summary

Alright, let’s get our hands dirty. Before you can make your site do backflips, you have to tell it how to stand up. That’s what this front matter is for. Think of it as the instruction sheet you slap on top of your content—a quick, machine-readable note that says, “Hey, Hugo, process this one like that.” We’re going to focus on the absolute non-negotiables, the fields you’ll use on nearly every single piece of content you create. Get these wrong, and the whole operation goes sideways.

6.1 Front Matter Formats: YAML (---), TOML (+++), JSON ({})

Right, let’s talk about the three ways you can tell your static site generator (or any other tool) what your content is about before it even reads the first paragraph. We call this “front matter,” and it’s the little data packet that lives at the top of your content files. It’s where you set the title, the publish date, the tags, and whatever else your heart desires. The format you choose says a lot about you, and at least two of these choices are correct.

— joke —

...