The Buttondown CLI creates a well-organized directory structure to store your newsletter content, media files, and sync state. This structure mirrors your Buttondown account and makes it easy to work with your content locally.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/buttondown/cli/llms.txt
Use this file to discover all available pages before exploring further.
Default Structure
When you runbuttondown pull, the CLI creates the following structure:
Directory Details
Root Directory
The root directory (default:./buttondown) contains all synced content. You can customize this location using the --directory flag:
.buttondown.json
This hidden file at the root tracks sync state and metadata. It’s automatically managed by the CLI and should not be manually edited. See the State File documentation for details.
Important: This file should be committed to version control to maintain sync state across team members and environments.
emails/ Directory
The emails directory contains all your newsletter emails as Markdown (.md) files. Each file represents a single email from your Buttondown account.
File Naming
Email files are named using either the email’s slug or ID:- If the email has a slug:
{slug}.md - If no slug exists:
{id}.md
Email File Format
Each email file contains YAML frontmatter followed by the email body:Frontmatter Fields
The following fields are stored in the frontmatter:id(string): Unique identifier from Buttondownsubject(string): Email subject lineemail_type(string): Type of email -public,private, orpremiumstatus(string): Publishing status -draft,scheduled, orpublishedslug(string): URL-friendly identifierpublish_date(string): ISO 8601 timestamp for publicationdescription(string): Meta description for SEOimage(string): Featured image URLcanonical_url(string): Canonical URL for SEOsecondary_id(number): Alternative identifiermetadata(object): Custom metadata fieldsfilters(object): Subscriber filters for sendingcommenting_mode(string): Comment settings -enabled,disabled, orpaid_onlyrelated_email_ids(array): IDs of related emailsfeatured(boolean): Whether the email is featured
media/ Directory
The media directory stores all images and attachments synced from Buttondown. Files are downloaded with their original filenames.
Supported File Types
The CLI syncs all media types supported by Buttondown, including:- Images:
.png,.jpg,.jpeg,.gif,.svg,.webp - Documents:
.pdf,.doc,.docx - Other: Any file uploaded to Buttondown
Organizing Media
You can organize media files into subdirectories:Working with the Structure
Adding New Content
Creating New Emails
Use thecreate command to generate a new email with proper structure:
emails/ with the required frontmatter:
Adding Media Files
Simply place files in themedia/ directory. When you run buttondown push, they’ll be uploaded to Buttondown and tracked in .buttondown.json.
Editing Content
Edit email files directly in your preferred text editor. The CLI preserves:- Frontmatter fields
- Markdown formatting
- Relative image references
- Line endings
Syncing Changes
After making local changes:Image References
The CLI supports both absolute and relative image references:Relative References (Recommended)
Reference local media files using relative paths:- Uploads the image to Buttondown
- Replaces the relative path with the Buttondown URL
- Tracks the mapping in
.buttondown.json
- Downloads the image to
media/ - Replaces the Buttondown URL with a relative path
Absolute URLs
You can also use absolute URLs for external images:Best Practices
Version Control
Commit these:.buttondown.json(tracks sync state)emails/*.md(your content)media/*(local assets)
Directory Organization
Keep your structure clean:- Use descriptive slugs for email files
- Organize media into subdirectories by type or date
- Don’t manually edit
.buttondown.json - Keep email filenames consistent with slugs
Collaboration
When working in a team:- Commit
.buttondown.jsonto share sync state - Pull before making changes:
buttondown pull - Push after editing:
buttondown push - Resolve conflicts by comparing frontmatter and body
Multiple Newsletters
Manage multiple newsletters with separate directories:.buttondown.json state file.
Custom Workflows
Programmatic Access
The directory structure is designed for programmatic access. You can:- Parse
.mdfiles using any YAML/Markdown library - Generate emails from templates
- Batch process media files
- Automate content generation