-
✅ Add frontmatter to files that don’t have it
-
✅ Modify specific fields without affecting others
-
✅ Retrieve frontmatter content or specific fields
-
✅ Delete frontmatter entirely or specific fields
-
✅ Nested field support with dot notation (
object.field) -
✅ Multiple operations in a single command
-
✅ Dry-run mode to preview changes
-
✅ Performance optimized for large files
-
✅ Safe atomic writes to prevent data corruption
-
✅ Exit codes for scripting and automation
frontmatter [get|set|delete] [--dry-run] [...] <file>Set a single field:
frontmatter set message="Hello World" file.mdSet nested fields with dot notation:
frontmatter set object.field=5 file.mdSet multiple fields at once:
frontmatter set a=1 b=value c="text with spaces" file.mdGet a specific field:
frontmatter get message file.mdGet the entire frontmatter:
frontmatter get file.mdThe tool automatically detects and handles various data types:
-
Strings:
message="Hello World" -
Integers:
count=42 -
Floats:
price=19.99 -
Booleans:
published=true -
Arrays:
tags=[tag1,tag2,tag3] -
Objects:
config={"key":"value"}
Create a new file with frontmatter:
echo "# My Article" > article.md
frontmatter set title="My First Post" author="John Doe" article.mdResult:
---
title: My First Post
author: John Doe
---
# My Articlefrontmatter set config.database.host="localhost" config.database.port=5432 article.mdResult:
---
config:
database:
host: localhost
port: 5432
---# Get specific field
frontmatter get title article.md
# Output: My First Post
# Get nested field
frontmatter get config.database.host article.md
# Output: localhost
# Get entire frontmatter as YAML
frontmatter get article.mdThe tool uses standard exit codes for scripting:
-
0- Success -
1- General error (invalid arguments, file errors, etc.) -
2- Not found (field doesn’t exist, no frontmatter found)
The tool is optimized for performance with large files:
-
Optimized I/O: Only reads frontmatter section for
getoperations -
Atomic writes: Uses temporary files to prevent corruption
-
Memory efficient: Streams large files instead of loading entirely into memory
The tool works with any text file containing YAML frontmatter:
-
Markdown files (
.md,.markdown) -
HTML files (
.html,.htm) -
Text files (
.txt) -
Any other text format
---
title: My Document
author: John Doe
date: 2025-06-06
tags: [example, demo]
config:
theme: dark
language: en
---
Your document content goes here...The project uses GitHub Actions for continuous integration and delivery:
-
Automated testing on multiple Go versions (1.21.x - 1.24.x)
-
Cross-platform builds (Linux, macOS, Windows, FreeBSD)
-
Security scanning with gosec
-
Automated releases with pre-built binaries
I’ll be happy to accept contributions! You can suggest changes, report issues, or submit pull requests. Let’s talk!
My idea for this tool is to be pretty minimal but do its thing well.
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.adoc for detailed version history and release notes.
-
Built with goccy/go-yaml for YAML processing