Content Files

Learn how to create and structure content files in Markdown and YAML formats for Content Mode.

Markdown Files

Markdown files (.md) are the most common format for content in Content Mode. They combine metadata (front matter) with content (body).

Structure

Markdown files have two parts:

  • Front Matter: YAML metadata at the top, enclosed by --- delimiters
  • Body: The main content written in Markdown, which is converted to HTML during build
---
title: "My First Post"
date: "2024-01-15T10:00:00Z"
author: "authors/john"
published: true

This is the body content in Markdown. You can use all standard Markdown syntax:
  • Lists
  • Bold and italic text
  • Links
  • Code blocks
console.log("Hello, World!");

YAML Files

YAML files (.yaml or .yml) are pure data files, perfect for structured content that doesn't need a body.

Use Cases

YAML files are ideal for:

  • Author profiles
  • Product data
  • Configuration data
  • Any content that's purely data-driven

Structure

YAML files contain only data, no body content:

name: "John Doe"
slug: "john"
bio: "Writer and developer"
avatar: "/uploads/john.jpg"
email: "john@example.com"
social:
  twitter: "@johndoe"
  github: "johndoe"

Front Matter Fields

Front matter is the YAML metadata section at the top of Markdown files. It defines properties about your content.

Standard Fields

These fields are available for all content:

  • title: Content title
  • slug: URL-friendly identifier (auto-generated if missing)
  • date: Publication date (ISO 8601 format)
  • published: Boolean (default: true if omitted)
  • scheduledDate: Future publication date (ISO 8601)

Custom Fields

You can add any custom fields defined in your collection configuration. For example:

---
title: "My Post"
date: "2024-01-15T10:00:00Z"
author: "authors/john"
category: "Technology"
tags: ["web", "development"]
featured: true
---

Relations

Reference other collections by slug using the format "collection-name/slug":

---
title: "My Post"
author: "authors/john"
category: "categories/web-development"
---

Date Formats

Dates should be in ISO 8601 format for consistency and proper parsing.

Recommended Format

Use full ISO 8601 format with timezone (UTC recommended):

date: "2024-01-15T10:00:00Z"

Other Formats

Hammer also accepts:

  • Date only: "2024-01-15"
  • With timezone: "2024-01-15T10:00:00-05:00"
Tip: Using UTC timezone (Z suffix) ensures consistency across different environments and timezones.

Best Practices

File Organization

  • Use descriptive filenames that reflect the content
  • Keep filenames URL-safe (lowercase, hyphens, no spaces)
  • Organize files logically within collection directories

Front Matter

  • Include all required fields defined in your collection config
  • Use ISO 8601 format for dates
  • Keep front matter organized and consistent
  • Use relations for linked content instead of duplicating data

Content Structure

  • Write clear, well-structured Markdown
  • Use headings to organize content
  • Keep content focused and readable
  • Use consistent formatting across files

Relations

  • Reference relations by slug (e.g., "authors/john")
  • Ensure referenced content exists
  • Use relations instead of duplicating data

Next Steps

Now that you understand content files, learn about: