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?
- Performance: Static sites load faster and are more reliable
- Cost: Free hosting on services like Netlify, Vercel, GitHub Pages
- Security: No PHP execution, reducing attack surface
- Scalability: Easy to serve via CDN for global performance
- Compatibility: Works with any static hosting service
Prerequisites
- FearlessCMS development server running on localhost:8000
- 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:
- Recursive crawling to depth 3
- Automatic asset downloading
- Link conversion to relative paths
- Comprehensive error handling
- Export statistics
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
- All HTML pages (home, blog, documentation, etc.)
- CSS stylesheets and theme files
- JavaScript files and plugins
- Images (PNG, JPG, GIF, SVG)
- Fonts (WOFF, WOFF2, TTF, EOT)
- Uploaded files and media
- Plugin-generated content
❌ Excluded
- PHP files (server-side code)
- Dynamic content requiring PHP
- Server-side only features
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
- Drag and drop the
export/
folder to Netlify - Your site is live instantly
- Automatic deployments on future exports
Vercel
- Connect your repository
- Set build output directory to
export/
- Deploy automatically on commits
GitHub Pages
- Create a
gh-pages
branch - Push the export folder contents
- Enable GitHub Pages in repository settings
AWS S3 + CloudFront
- Upload export folder to S3 bucket
- Configure CloudFront distribution
- Set S3 bucket as origin
Traditional Hosting
- Upload via FTP/SFTP
- Point domain to export folder
- 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"
- Ensure development server is running
- Check if port 8000 is available
- Verify firewall settings
Empty or incomplete exports
- Increase wait time between requests
- Check server logs for errors
- Ensure all pages are accessible via browser
Missing assets
- Verify file permissions on server
- Check for absolute vs. relative paths
- Review browser console for 404 errors
Large export files
- Exclude unnecessary file types
- Reduce crawl depth
- Use selective export scripts
Performance Optimization
- Reduce crawl depth for large sites
- Increase wait time to avoid overwhelming server
- Use selective crawling for specific sections
- Exclude unnecessary file types to reduce size
Best Practices
- Test thoroughly before deploying
- Use staging environment for testing exports
- Monitor export size and optimize as needed
- Set up automated exports for production sites
- Keep backups of original dynamic site
- Document custom configurations for team members
Migration from Old Export System
If you were using the previous Node.js export script:
- Stop using the old
export.js
script - Use the new scripts:
./export-wget.sh
is recommended - Update deployment process to use new export directory
- Test thoroughly to ensure all content is exported correctly
Support
For issues with the export system:
- Check the troubleshooting section above
- Review server logs for errors
- Test with a simple site first
- Verify all prerequisites are met
- 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.