9.6 Using hugo new Effectively in Your Workflow
Right, let’s talk about hugo new. This is one of those commands that seems trivial until you realize it’s the entire foundation for not driving yourself insane. It’s Hugo’s way of saying, “Don’t start from an empty file, you maniac. Start from a smart empty file.” Think of it as your personal content factory. You give it a blueprint (an archetype), and it stamps out a new page with all the right front matter fields already filled in, or at least politely suggested. This isn’t just about convenience; it’s about consistency. It ensures your blog/ posts all have a description field and your work/case-studies/ all have a client_name field. Without it, you’re just raw-dogging YAML in a text editor, and I respect you too much to let you do that. How It Actually Works (The Magic Trick Explained) You run hugo new content/path/to/your-page.md. Hugo isn’t just creating a folder and a file. It’s much smarter than that. It looks at that path and tries to match it to a content type. It does this by looking for a directory inside your content/ folder that matches the first part of the path. So, if you run: hugo new blog/2024/my-amazing-post.md Hugo sees blog/ and thinks, “Aha! This is a ‘blog’ type of content.” It then goes looking for a blueprint specifically for the ‘blog’ type, which is a file called archetypes/blog.md. If it finds one, it uses that as the template. If it doesn’t, it falls back to the default archetypes/default.md. Let’s make this concrete. Say you have this archetype at archetypes/blog.md: --- title: "{{ replace .File.ContentBaseName "-" " " | title }}" date: {{ .Date }} draft: true description: "" categories: [] tags: [] --- Summary intro goes here. Your brilliant content here. When you run that hugo new command, it creates content/blog/2024/my-amazing-post.md and populates it with: