TheDocumentation 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.
.buttondown.json file is automatically created and managed by the Buttondown CLI to track synchronization state between your local files and Buttondown. This file is crucial for efficient syncing and preventing duplicate uploads.
Location
The state file is located at the root of your Buttondown directory:Purpose
The state file serves several important purposes:- Media Tracking: Maps local media files to their Buttondown URLs and IDs
- Duplicate Prevention: Prevents re-uploading files that already exist
- Reference Resolution: Enables converting between relative paths and absolute URLs
- Sync Efficiency: Allows the CLI to determine what needs to be synced
File Format
The state file is a JSON file with the following structure:Structure Details
Root Object
The root object contains a single property:A mapping of image IDs to their sync information. Each key is a unique image ID from Buttondown.
SyncedImage Object
Each entry insyncedImages contains the following fields:
The unique identifier for the image in Buttondown. This matches the key in the parent object.Example:
"abc123-def456-789"The absolute path to the file on your local filesystem. This is used to match local files with their remote counterparts.Example:
"/Users/jane/projects/newsletter/buttondown/media/banner.png"Note: This is always an absolute path, even though emails reference media using relative paths.The full URL where the image is hosted on Buttondown’s servers. This is the URL that appears in published emails.Example:
"https://buttondown.s3.amazonaws.com/images/abc123/banner.png"The original filename of the media file. This is used when downloading files from Buttondown.Example:
"banner.png"Example State File
Here’s a complete example with multiple synced images:How It’s Used
During Pull Operations
When you runbuttondown pull, the CLI:
- Downloads all images from Buttondown
- Saves them to the
media/directory - Records their IDs, URLs, and local paths in
.buttondown.json - Replaces absolute URLs in emails with relative paths
During Push Operations
When you runbuttondown push, the CLI:
- Scans emails for relative image references (e.g.,
../media/image.png) - Checks if the local file is already tracked in
.buttondown.json - If tracked: Uses the existing URL
- If not tracked: Uploads the file and adds it to
.buttondown.json - Replaces relative paths with absolute URLs before sending to Buttondown
Avoiding Duplicate Uploads
The state file prevents the same file from being uploaded multiple times:Managing the State File
Version Control
You should commit.buttondown.json to version control. This allows:
- Team members to share sync state
- Consistent image URLs across environments
- Avoiding duplicate uploads when switching machines
Manual Editing
Generally, you should not manually edit this file. The CLI manages it automatically. However, if you need to:- Ensure valid JSON syntax
- Keep the structure consistent
- Use absolute paths for
localPath - Match the
idfield with the object key
Resetting State
If the state file becomes corrupted or out of sync, you can delete it:buttondown pull to rebuild it:
Moving Directories
If you move your Buttondown directory, the absolute paths in.buttondown.json will be incorrect. Fix this by:
- Delete the state file
- Run
buttondown pullto recreate it with correct paths
Common Issues
Missing State File
Symptom: No.buttondown.json file after running buttondown pull
Cause: The directory may not have write permissions, or the pull failed
Solution: Check directory permissions and run buttondown pull again
Incorrect Image URLs
Symptom: Images in pushed emails have wrong URLs Cause: State file paths don’t match actual file locations Solution: Delete.buttondown.json and run buttondown pull to rebuild
Duplicate Uploads
Symptom: Same images uploaded multiple times with different IDs Cause: State file not shared across team members or machines Solution:- Commit
.buttondown.jsonto version control - Pull latest state before pushing changes
- Ensure all team members use the same directory structure
Large State File
Symptom:.buttondown.json is very large (>1MB)
Cause: Many synced images over time
Impact: This is normal and shouldn’t cause issues. The file is read/written infrequently.
Advanced Usage
Programmatic Access
You can read the state file programmatically:Custom Image Organization
If you reorganize yourmedia/ directory, update the state file: