A lightweight PHP static site generator for GitHub projects that creates a professional documentation website with minimal configuration.
This tool automatically generates a static website based on your GitHub repository content. It pulls README.md and other Markdown files from your repo, converts them to HTML, and creates a fully functioning website with navigation, download page, and support functionality.
- Home page generated from
README.md - Additional Markdown pages (e.g.,
INSTALLATION.md,TROUBLESHOOTING.md) - Download page with GitHub Releases information
- Support page with:
- List of open GitHub issues
- Contact form with email notifications
- Code syntax highlighting with highlight.js
- Sponsor page with donation links from GitHub FUNDING.yml
- Local caching for faster generation
- Favicon customization
- Theme customization options
- Clone this repository:
git clone https://github.com/magicoli/php-site-generator.git
cd php-site-generator- Install dependencies:
composer install- Create configuration file:
cp config.json.example config.json-
Edit
config.jsonwith your project details -
Generate the site:
php generate.php- Set up a cron task to automatically update your site:
# Edit crontab
crontab -e
# Add a line to run the generator hourly (adjust the path as needed)
0 * * * * cd /home/path/to/php-site-generator && php generate.php >> /var/log/site-generator.log 2>&1The cron task will automatically rebuild your site on a regular schedule, keeping the content in sync with your GitHub repository.
Edit config.json to configure your site:
{
"title": "My GitHub Project",
"github_user": "user",
"repo": "my-repo",
"github_branch": "master",
"github_token": "your_token_here",
"support_email": "[email protected]",
"sender_email": "[email protected]",
"output_folder": "output",
"menu": [
{ "title": "About", "file": "/" },
{ "title": "Download", "file": "download" },
{ "title": "Installation", "file": "INSTALLATION.md" },
{ "title": "Troubleshooting", "file": "TROUBLESHOOTING.md" },
{ "title": "Support", "file": "support" }
]
}Important configuration options:
github_token: Optional, helps avoid API rate limitationssupport_email: Required for the support form to functionsender_email: Optional, defaults to support_email if not setoutput_folder: your website root directory (e.g. /var/www/html)
/php-site-generator/
├── config.json // Configuration for the site and pages
├── generate.php // Main script to generate the static site
├── template.php // HTML template for the pages
├── vendor/ // Composer dependencies (Parsedown)
├── assets/ // CSS, images
│ └── style.css // Custom styling
└── pages/ // Local Markdown files and templates
├── download.md // Template for download page
├── support.md // Template for support page
└── partials/ // Reusable page components
└── support_form.php // Support form template
../www/ // Generated static site (output folder defined in config.json)
├── assets
│ └── style.css
├── download.html
├── index.html
├── installation.html
├── support.php // PHP for dynamic support form
├── support_form.php // Included in support.php
└── troubleshooting.html
The generate.php script:
- Loads your configuration
- Fetches content from your GitHub repository
- Processes Markdown files into HTML
- Creates special pages like download and support
- Assembles a complete website with navigation
- Outputs everything to your specified folder
AGPL-3.0
- Parsedown for Markdown parsing
- Bootstrap for responsive layout
- highlight.js for code syntax highlighting