Front matter format
Hugo supports multiple front matter formats. The benson.vc site uses TOML format, which is enclosed in+++ markers:
Alternative formats
Hugo also supports YAML (enclosed in---) and JSON formats, but TOML is recommended for consistency with the existing site.
Required fields
These fields should be included in every post:title
The title of your post, displayed as the page heading and in listings:- Use title case or sentence case consistently
- Wrap the value in single quotes
- Special characters and apostrophes are supported
date
The publication date and time for your post:- Use RFC 3339 format:
YYYY-MM-DDTHH:MM:SS-TZ:TZ - Include timezone information (e.g.,
-08:00for PST) - Hugo uses this for sorting posts chronologically
- The date appears in post listings and on the post page
draft
Controls whether the post is published or hidden:draft = false- Post is published and visible in productiondraft = true- Post is hidden unless running with-Dflag- Use drafts while writing and reviewing content
Optional fields
robots
Control search engine indexing for the post:'index, follow'- Allow indexing and following links (default)'noindex, nofollow'- Prevent indexing and following links'noindex, follow'- Prevent indexing but allow following links'index, nofollow'- Allow indexing but prevent following links
description
A brief summary of the post for SEO and social sharing:- Keep it concise (150-160 characters)
- Used in meta tags and social media previews
- Improves SEO and click-through rates
tags
Categorize your post with tags:- Use an array of strings
- Tags can be used for filtering and organization
- Congo theme can display tags on post pages
categories
Group posts into broader categories:- Use an array of strings
- Typically broader than tags
- Creates category taxonomy pages
author
Specify the post author:- Can be a string or reference to author data
- Congo theme can display author information
slug
Customize the URL slug for the post:- Overrides the default slug generated from the directory name
- Use lowercase and hyphens
- Useful for shorter or more readable URLs
aliases
Create redirect aliases for the post:- Maintains old URLs when restructuring content
- Hugo creates redirect pages automatically
- Preserves SEO value and prevents broken links
Real example
Here’s the complete front matter from a real post on the benson.vc site:Extended example
Here’s what a more comprehensive front matter configuration might look like:Date formatting
Common questions
What happens if I don't include a date?
What happens if I don't include a date?
Hugo will use the file creation date or last modification date as a fallback. However, it’s best practice to always include an explicit date field for consistency and control over post ordering.
Can I use different timezones for different posts?
Can I use different timezones for different posts?
Yes, each post can have its own timezone. Hugo will handle timezone conversions and sort posts correctly based on absolute time. This is useful if you’re publishing from different locations or want to schedule posts for specific timezones.
How do I schedule posts for future publication?
How do I schedule posts for future publication?
Set the
date field to a future date and time. By default, Hugo won’t publish posts with future dates unless you run hugo with the --buildFuture flag. This allows you to prepare content in advance.What's the difference between draft and publishDate?
What's the difference between draft and publishDate?
The
draft field is a boolean that marks content as unpublished. The publishDate field (not shown in the examples) lets you specify when a post should become visible. Use draft = true for work-in-progress content and publishDate for scheduled publishing.Can I add custom front matter fields?
Can I add custom front matter fields?
Yes! You can add any custom fields you want. They won’t affect Hugo’s core functionality, but you can access them in your templates. This is useful for theme-specific features or custom data.
Best practices
- Always include
title,date, anddraftfields - Use consistent date formatting across all posts
- Add
descriptionfor better SEO - Use
draft = truewhile writing, set tofalsewhen ready to publish - Keep titles concise and descriptive
- Use tags and categories for better content organization
- Test locally before publishing to verify front matter is correct