4.7 Module Configuration for Hugo Modules

Right, let’s talk about modules. This is where Hugo goes from being a nifty static site generator to a full-blown dependency management powerhouse. Think of it as npm or go mod for your Hugo site, but thankfully, with far less node_modules-induced existential dread. You’re not just managing themes anymore; you’re stitching together content, layouts, and assets from multiple sources into one coherent site. It’s brilliant, but it demands a bit of configuration finesse.

4.6 Security Policy Configuration

Right, let’s talk about locking this thing down. You’ve built a site, it looks fantastic, and now you’re thinking about putting it on the internet—that digital neighborhood where everyone’s a critic and some are just plain malicious. Hugo, being the sensible static site generator it is, gives you a few levers to pull to manage security headers via the hugo.toml file. This isn’t about server hardening (that’s on you and your hosting provider); this is about telling the user’s browser how to behave when it’s viewing your site. It’s a set of instructions, a policy, and getting it right is the difference between a robust site and a digital welcome mat for trouble.

4.5 The .Site Object in Templates: Accessing Configuration

Alright, let’s talk about the .Site object. This is your golden ticket, your backstage pass to all the global configuration and metadata you so cleverly defined in your hugo.toml (or hugo.yaml, or hugo.json—I don’t judge). Think of it as the Grand Central Station for your site’s data. It’s how your templates get access to everything from your site’s title to your custom parameters. While you can access some of this stuff via the global site variable (note the lowercase), .Site is the more fully-featured, canonical way to do it, especially within a template’s scope. They often point to the same underlying data, but I stick with .Site because it’s explicit and you’ll see it in 99% of the examples out there.

4.4 Environment-Specific Config: config/_default/, config/production/

Right, let’s talk about environments. Because your local machine is a pristine, forgiving paradise, and the public internet is a chaotic, resource-starved hellscape. You and I develop in the former and deploy to the latter, and we’d be fools to use the same configuration for both. Hugo knows this, and its environment-based configuration system is one of its most brilliant, sanity-saving features. We’re going to set it up so you can swear freely in your development console without it showing up on your company’s homepage.

4.3 Build Options: minify, disableKinds, buildDrafts

Right, let’s talk about the knobs and levers that actually determine what gets built when you run hugo. This isn’t about content; it’s about the build process itself. Think of it as the instructions you give to the factory foreman (Hugo) before he yells at the assembly line robots to start working. Get this wrong, and you’ll either ship a bloated, half-finished mess or a site that’s missing its most important pages. Let’s get it right.

4.2 The params Section: Custom Variables for Templates

Right, the params section. This is where Hugo, in a moment of clarity, gives you a key to a locked drawer in its brain. You can put whatever you want in that drawer—a string, a number, a list of your favorite 80s action heroes—and then later, in your templates, you can pull it out and use it. It’s the primary way you pass custom configuration from your central hugo.toml file directly into your templates to control how they look and behave.

4.1 Top-Level Config Keys: baseURL, languageCode, title, theme

Right, let’s talk about the brainstem of your Hugo site: the hugo.toml file (or hugo.yaml or hugo.json—I don’t judge your life choices, but I’ll be using TOML because it’s the default and frankly, it’s fine). This is where you tell Hugo the absolute essentials it needs to not trip over its own feet and fall flat on its face when you run hugo. We’re going to focus on the big four top-level keys you absolutely must get right from the start.

— joke —

...