Guide: Managing Articles
Learn how to build and manage a blog with PageGun's API. This guide covers creating articles, SEO optimization, bulk operations, and content workflows.
Prerequisites
- A PageGun project with an API key
- Basic knowledge of REST APIs and Markdown
Creating Your First Article
export PAGEGUN_API_KEY="your-api-key"
export PROJECT_ID="proj_abc123"
curl -X POST "https://api.pagegun.com/pages" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"page_name\": \"Getting Started with PageGun\",
\"slug\": \"getting-started\",
\"subroute\": \"blog\",
\"type\": \"article\",
\"project_id\": \"$PROJECT_ID\",
\"description\": \"Learn how to build your first site with PageGun in under 5 minutes.\",
\"og_image_url\": \"https://example.com/blog/getting-started-og.jpg\",
\"markdown_content\": \"# Getting Started with PageGun\n\nPageGun makes it easy to build sites programmatically. In this guide, we will walk through the basics.\n\n## Step 1: Get Your API Key\n\nSign up at [pagegun.com](https://pagegun.com) and generate an API key from your dashboard.\n\n## Step 2: Create a Project\n\n\`\`\`bash\ncurl -X POST https://api.pagegun.com/projects ...\n\`\`\`\n\n## Step 3: Create Your First Page\n\nUse the Pages API to create content...\"
}"SEO Optimization
Essential Fields
Every article should include:
| Field | SEO Impact | Example |
|---|---|---|
page_name | Page title + H1 | "How to Build Landing Pages with API" |
description | Meta description (155 chars max) | "Learn to create landing pages programmatically with PageGun's REST API." |
og_image_url | Social sharing image | 1200×630px recommended |
slug | URL path (include keywords) | build-landing-pages-api |
Slug Best Practices
| ❌ Bad Slug | ✅ Good Slug |
|---|---|
post-1 | getting-started-with-pagegun |
article_2024_01 | build-landing-pages-api |
untitled | pagegun-vs-wordpress-comparison |
- Use lowercase, hyphen-separated words
- Include target keywords
- Keep under 60 characters
- Avoid dates in slugs (content becomes "evergreen")
Markdown Content Tips
# Primary Heading (matches page_name)
Introduction paragraph with your target keyword naturally included.
## Subheading with Secondary Keyword
Content organized in scannable sections...
### Use H3 for Sub-sections
- Bullet points for lists
- **Bold** for emphasis
- [Internal links](/docs/api-reference/pages/list) for navigation
> Blockquotes for important callouts
\`\`\`bash
# Code examples for developers
curl -X GET "https://api.pagegun.com/pages"
\`\`\`Updating Articles
# Get current article
curl -s "https://api.pagegun.com/pages/PAGE_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" | jq '.data.markdown_content'
# Update content
curl -X PUT "https://api.pagegun.com/pages/PAGE_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown_content": "# Updated Title\n\nNew content here..."}'
# Re-publish to push changes live
curl -X POST "https://api.pagegun.com/pages/PAGE_ID/publish" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"Bulk Operations
List All Articles
curl -s "https://api.pagegun.com/pages?project_id=$PROJECT_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
| jq '.data[] | select(.type == "article") | {id, title: .page_name, slug, status}'Publish All Draft Articles
DRAFTS=$(curl -s "https://api.pagegun.com/pages?project_id=$PROJECT_ID" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
| jq -r '.data[] | select(.type == "article" and .status == "draft") | .id')
for ID in $DRAFTS; do
curl -s -X POST "https://api.pagegun.com/pages/$ID/publish" \
-H "Authorization: Bearer $PAGEGUN_API_KEY"
echo "Published: $ID"
sleep 0.5
doneContent Workflow
A recommended workflow for teams and AI agents:
- Draft — Create article via API with
status: "draft" - Review — Fetch and review content
- Publish — Call the publish endpoint
- Monitor — Track performance via analytics
- Update — Refresh content, re-publish
Displaying Articles
Add an Articles Grid section to any page type page to display your articles:
{
"type": "articles-grid",
"heading": "Latest Posts",
"columns": 3,
"limit": 6
}Related
- Page Type: Article — Article reference
- Articles Grid Section — Display articles in a grid
- API: Create Page — Create any page type