Beehiiv Cross-Posting Integration
Beehiiv Cross-Posting Integration
Automatically cross-post Jekyll blog posts from GitHub Pages to Beehiiv using GitHub Actions.
⚠️ Setup Required
This integration is NOT YET ACTIVE. See ../SETUP.md for complete setup instructions.
Quick Start: You need to:
- Request Beehiiv Enterprise API access
- Configure GitHub Secrets
- Verify API integration
- See
../SETUP.mdfor detailed steps
Overview
This integration enables dual publishing:
- Primary: GitHub Pages (mrogers.london) - SEO indexed
- Secondary: Beehiiv web + email - subscribers only (not indexed)
Posts are automatically synced when you push to the main branch.
Prerequisites
1. Request Beehiiv API Access
You need Enterprise-level API access from Beehiiv:
- Log into your Beehiiv dashboard
- Visit the Help page or use the Chatbot Assistant
- Request access to the “Send API” / “Create Post” endpoint
- Wait for approval and obtain your API key
Documentation:
2. Configure GitHub Secrets
Add these secrets to your GitHub repository (Settings → Secrets and variables → Actions):
BEEHIIV_API_KEY- Your Beehiiv API keyBEEHIIV_PUBLICATION_ID- Your Beehiiv publication ID
3. Enable “Remove Indexing” in Beehiiv
After the integration is working:
- Go to Beehiiv Settings → Publication Settings
- Toggle “Disable Indexing” ON
- This prevents Google from indexing your Beehiiv site (avoids duplicate content)
Reference: Beehiiv SEO Options
How It Works
Automatic Sync (GitHub Actions)
When you push to the main branch:
- GitHub Actions workflow (
beehiiv-sync.yml) triggers - Python script (
sync_to_beehiiv.py) runs - Script scans
_posts/for new or updated posts - Markdown content is converted to HTML
- Posts are created/updated on Beehiiv via API
- State file (
.beehiiv_sync_state.json) is updated
State Tracking
The .beehiiv_sync_state.json file tracks which posts have been synced:
{
"synced_posts": {
"2025-04-13-fat-tails-and-model-collapse": {
"beehiiv_post_id": "abc123",
"synced_at": "2025-04-13T10:00:00Z",
"content_hash": "sha256hash",
"title": "Fat tails & model collapse"
}
},
"last_sync": "2025-04-13T10:00:00Z"
}
The script uses content hashing to detect when posts are updated.
Local Testing
Test the sync script locally before deploying:
# Set environment variables
export BEEHIIV_API_KEY="your_api_key_here"
export BEEHIIV_PUBLICATION_ID="your_publication_id_here"
# Install dependencies
pip install -r scripts/requirements.txt
# Run sync script
python scripts/sync_to_beehiiv.py
Expected output:
============================================================
Beehiiv Sync Starting
============================================================
Found 5 post(s)
------------------------------------------------------------
Processing: 2025-04-13-fat-tails-and-model-collapse.md
⊕ New post, creating...
✓ Post created on Beehiiv: Fat tails & model collapse (ID: abc123)
[... more posts ...]
============================================================
Sync Complete
============================================================
New posts created: 5
Existing posts updated: 0
Posts skipped: 0
Errors: 0
============================================================
Publishing Workflow
New Post
- Write post in
_posts/YYYY-MM-DD-slug.md - Commit and push to main branch
- Automatic:
- Jekyll builds and deploys to GitHub Pages
- Beehiiv sync runs and cross-posts
- Post appears on:
- mrogers.london (SEO-indexed)
- Beehiiv web (subscribers only)
- Beehiiv email (sent to subscribers)
Update Existing Post
- Edit markdown file in
_posts/ - Commit and push to main
- Sync script detects content hash change
- Post automatically updates on Beehiiv
Zero manual work after setup!
Manual Trigger
You can manually trigger the sync workflow:
- Go to GitHub Actions tab in your repo
- Select “Sync to Beehiiv” workflow
- Click “Run workflow”
- Select the
mainbranch - Click “Run workflow” button
This is useful for:
- Initial backfill of existing posts
- Testing after setup
- Re-syncing if automatic sync fails
Troubleshooting
Workflow Fails: Missing API Key
Error: BEEHIIV_API_KEY environment variable not set
Solution:
- Go to GitHub repo Settings → Secrets and variables → Actions
- Add
BEEHIIV_API_KEYsecret with your API key - Re-run the workflow
Workflow Fails: Authentication
Error: Authentication failed. Check BEEHIIV_API_KEY
Solution:
- Verify your API key is correct
- Ensure you have Enterprise API access approved
- Check API key hasn’t expired
Posts Not Appearing on Beehiiv
Possible causes:
- API request failed (check workflow logs)
- Post is in draft status (should be “confirmed”)
- Beehiiv settings prevent publishing
Debug:
- Check GitHub Actions logs for errors
- Verify state file was updated
- Check Beehiiv dashboard for draft posts
Images Not Loading in Beehiiv Emails
Cause: Images are hosted on GitHub Pages
Solution:
- Ensure GitHub Pages is deployed and accessible
- Verify image URLs in HTML are absolute (
https://mrogers.london/assets/...) - Check
_site/directory contains images after build
Rollback
If you need to disable the integration:
- Rename the workflow file:
mv .github/workflows/beehiiv-sync.yml .github/workflows/beehiiv-sync.yml.disabled - Commit and push
Your GitHub Pages site continues working normally. Beehiiv posts remain (delete manually if needed).
Files
scripts/sync_to_beehiiv.py- Main sync script (~250 lines)scripts/requirements.txt- Python dependencies.github/workflows/beehiiv-sync.yml- GitHub Actions workflow.beehiiv_sync_state.json- Sync state tracking (auto-generated)
Support
For issues with:
- This script: Create an issue in this repo
- Beehiiv API: Contact Beehiiv support
- GitHub Actions: Check GitHub Actions documentation