Guide: Building a Docs Site

Build a complete developer documentation site with PageGun. This guide covers navigation structure, page organization, content formatting, and deployment.

Prerequisites

  • A PageGun project with a custom domain (or using the default *.pagegun.com subdomain)
  • An API key

Planning Your Structure

Before creating pages, plan your documentation tree:

docs/
├── introduction           → Welcome page, overview
├── quick-start            → Get users to first success fast
├── concepts/
│   ├── overview           → Core concepts explained
│   └── hosting            → Hosting modes comparison
├── api-reference/
│   ├── introduction       → API overview, base URL, auth
│   ├── authentication     → API key management
│   ├── projects           → Projects endpoints
│   ├── pages              → Pages endpoints
│   └── errors             → Error codes reference
└── guides/
    ├── landing-page       → Build a landing page
    ├── blog-setup         → Set up a blog
    └── webhooks           → Configure webhooks

PageGun auto-generates navigation from page slugs:

  • Top-level pages: introduction, quick-start → appear as root nav items
  • Nested pages: api-reference/authentication → "API Reference" folder with "Authentication" inside
  • Folder names: Derived from slug segments — api-reference becomes "API Reference"
  1. Navigation is regenerated when any docs page is published
  2. Only published pages appear in navigation
  3. Pages are sorted alphabetically by slug within each folder
  4. Use number prefixes for custom ordering: 01-introduction, 02-quick-start

Important: Changing project settings alone does NOT regenerate navigation. You must publish at least one docs page.

Creating Pages

Introduction Page

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\": \"Introduction\", \"slug\": \"introduction\", \"subroute\": \"docs\", \"type\": \"docs\", \"project_id\": \"$PROJECT_ID\", \"description\": \"Welcome to our API documentation.\", \"markdown_content\": \"# Introduction\n\nWelcome to our documentation. This guide covers everything you need to get started.\n\n## Overview\n\nOur API lets you...\", \"config\": { \"sections\": [] } }"

Nested Page (in a Folder)

curl -X POST "https://api.pagegun.com/pages" \ -H "Authorization: Bearer $PAGEGUN_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"page_name\": \"Authentication\", \"slug\": \"api-reference/authentication\", \"subroute\": \"docs\", \"type\": \"docs\", \"project_id\": \"$PROJECT_ID\", \"markdown_content\": \"# Authentication\n\n## API Keys\n\nAll requests require a Bearer token in the Authorization header:\n\n\`\`\`\nAuthorization: Bearer your-api-key\n\`\`\`\n\n## Getting Your Key\n\n1. Go to your [Dashboard](https://pagegun.com/dashboard)\n2. Navigate to Settings → API Keys\n3. Click Generate New Key\", \"config\": { \"sections\": [] } }"

Remember: Always include "config": { "sections": [] } for docs pages.

Batch Creation Script

For large documentation sites, script the creation:

#!/bin/bash API_KEY="your-api-key" PROJECT_ID="proj_abc123" BASE="https://api.pagegun.com" create_doc() { local name="$1" slug="$2" content="$3" RESPONSE=$(curl -s -X POST "$BASE/pages" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"page_name\": \"$name\", \"slug\": \"$slug\", \"subroute\": \"docs\", \"type\": \"docs\", \"project_id\": \"$PROJECT_ID\", \"markdown_content\": \"$content\", \"config\": { \"sections\": [] } }") PAGE_ID=$(echo "$RESPONSE" | jq -r '.data.id') # Publish immediately curl -s -X POST "$BASE/pages/$PAGE_ID/publish" \ -H "Authorization: Bearer $API_KEY" echo "✅ $name ($slug) → $PAGE_ID" } create_doc "Introduction" "introduction" "# Welcome\n\nGetting started guide..." create_doc "Authentication" "api-reference/authentication" "# Auth\n\nAPI key setup..." create_doc "Projects" "api-reference/projects" "# Projects API\n\nManage projects..."

Content Formatting Tips

Code Blocks

Specify the language for syntax highlighting:

```javascript const response = await fetch('https://api.example.com/pages', { headers: { 'Authorization': `Bearer ${apiKey}` } }); ```

Cross-References

Link to other docs pages using relative paths:

See the [Authentication guide](/docs/api-keys) for setup instructions.

Callouts

Use blockquotes for notes and warnings:

> **Note**: This feature requires a Pro plan. > **⚠️ Warning**: This action cannot be undone.

Tables

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `name` | string | Yes | Project name | | `domain` | string | No | Custom domain |

Deployment

After creating all pages, publish them in batch:

# Get all docs pages PAGES=$(curl -s "$BASE/pages?project_id=$PROJECT_ID" \ -H "Authorization: Bearer $API_KEY" \ | jq -r '.data[] | select(.type == "docs") | .id') # Publish all for ID in $PAGES; do curl -s -X POST "$BASE/pages/$ID/publish" \ -H "Authorization: Bearer $API_KEY" sleep 0.3 done echo "✅ All docs published. Navigation regenerated."
© 2026 PageGun. All rights reserved.