Export Sites to Static HTML

FearlessCMS includes powerful export functionality that allows you to convert your dynamic PHP-based site into static HTML files for deployment to static hosting services like Netlify, Vercel, GitHub Pages, and more.

Overview

The export system crawls your running FearlessCMS site and downloads all HTML pages, CSS stylesheets, JavaScript files, images, and other assets, creating a completely static version that can be deployed anywhere.

Why Use Static Export?

Prerequisites

  1. FearlessCMS development server running on localhost:8000
  2. curl - Required for the export script

Starting the Development Server

Important: The PHP development server must be running for the export script to work. Start it with:

nix-shell -p php81 --run "export FCMS_DEBUG=true && ./serve.sh"

This will start the server on localhost:8000, which the export script needs to crawl and download your site.

Installing curl

Ubuntu/Debian:

sudo apt install curl

CentOS/RHEL:

sudo yum install curl

macOS:

brew install curl

NixOS:

nix-env -iA nixpkgs.curl

Export Method

Using the Export Script

The export-robust.sh script provides comprehensive site crawling:

./export-robust.sh

Features:

Configuration

You can customize the export process by editing the script variables:

# In export-robust.sh
EXPORT_DIR="export"           # Output directory
BASE_URL="http://localhost:8000"  # Source URL
DEPTH=3                       # Crawl depth
WAIT=1                        # Wait between requests

What Gets Exported

✅ Included

❌ Excluded

Output Structure

export/
├── index.html                 # Home page
├── dev-roadmap/
│   └── index.html            # Development roadmap
├── documentation/
│   └── index.html            # Documentation
├── blog/
│   ├── index.html            # Blog index
│   └── [post-slug]/
│       └── index.html        # Individual blog posts
├── themes/
│   └── default/
│       └── assets/
│           └── style.css     # Theme styles
├── uploads/                   # User uploads
└── assets/                    # Other assets

Deployment

Netlify

  1. Drag and drop the export/ folder to Netlify
  2. Your site is live instantly
  3. Automatic deployments on future exports

Vercel

  1. Connect your repository
  2. Set build output directory to export/
  3. Deploy automatically on commits

GitHub Pages

  1. Create a gh-pages branch
  2. Push the export folder contents
  3. Enable GitHub Pages in repository settings

AWS S3 + CloudFront

  1. Upload export folder to S3 bucket
  2. Configure CloudFront distribution
  3. Set S3 bucket as origin

Traditional Hosting

  1. Upload via FTP/SFTP
  2. Point domain to export folder
  3. Configure web server for static files

Advanced Usage

Custom Export Scripts

You can create custom export scripts for specific needs:

#!/bin/bash
# Custom export script
EXPORT_DIR="custom-export"
BASE_URL="http://localhost:8000"
DEPTH=5

wget \
    --recursive \
    --level=$DEPTH \
    --page-requisites \
    --adjust-extension \
    --convert-links \
    --directory-prefix="$EXPORT_DIR" \
    "$BASE_URL"

Scheduled Exports

Set up automated exports using cron:

# Export every day at 2 AM
0 2 * * * cd /path/to/fearlesscms && ./export-wget.sh

CI/CD Integration

Integrate with GitHub Actions or other CI/CD systems:

# .github/workflows/export.yml
name: Export Site
on:
  push:
    branches: [main]
jobs:
  export:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Start FearlessCMS
        run: |
          # Start server and export
          ./export-wget.sh
      - name: Deploy to Netlify
        uses: nwtgck/actions-netlify@v1.2
        with:
          publish-dir: './export'

Troubleshooting

Common Issues

"Cannot connect to localhost:8000"

Empty or incomplete exports

Missing assets

Large export files

Performance Optimization

Best Practices

  1. Test thoroughly before deploying
  2. Use staging environment for testing exports
  3. Monitor export size and optimize as needed
  4. Set up automated exports for production sites
  5. Keep backups of original dynamic site
  6. Document custom configurations for team members

Migration from Old Export System

If you were using the previous Node.js export script:

  1. Stop using the old export.js script
  2. Use the new scripts: ./export-wget.sh is recommended
  3. Update deployment process to use new export directory
  4. Test thoroughly to ensure all content is exported correctly

Support

For issues with the export system:

  1. Check the troubleshooting section above
  2. Review server logs for errors
  3. Test with a simple site first
  4. Verify all prerequisites are met
  5. Check the FearlessCMS community forums

Examples

Basic Export

# Start server
nix-shell -p php81 --run "export FCMS_DEBUG=true && ./serve.sh"

# In another terminal, export
./export-wget.sh

Custom Export Directory

# Edit script to change export directory
sed -i 's/EXPORT_DIR="export"/EXPORT_DIR="my-static-site"/' export-wget.sh
./export-wget.sh

Selective Export

# Export only specific sections by modifying the script
# or by running multiple targeted exports

The export system provides a robust, maintainable way to create static versions of your FearlessCMS sites, ensuring compatibility with all plugins and themes while maintaining the flexibility to deploy anywhere.