generate-static-site Command
Note: This command is implemented as part of the
@pinstripe/static-sitepackage and needs to be included in your project for it to be available.
Interface
The command generates a static site from your Pinstripe application:
pinstripe generate-static-site
Parameters
No parameters required.
Examples
# Generate static site files
pinstripe generate-static-site
# Build script usage (common in package.json)
"build": "rm -rf build && pinstripe generate-static-site"
Description
The generate-static-site command is a static site generator that creates deployable static files from your Pinstripe application by:
- Page discovery - Finds all available view routes in your application
- Intelligent crawling - Starts with discovered routes and follows internal links
- Content generation - Renders each page using the callHandler service
- File organization - Saves static files with proper paths and extensions
- Asset handling - Processes HTML, CSS, JS and other content types
Generated File Structure
build/static/
├── index.html # Root page (/)
├── about.html # /about page
├── posts/
│ ├── index.html # /posts/ listing page
│ └── my-post.html # /posts/my-post individual page
├── assets/
│ ├── style.css # Stylesheets
│ └── script.js # JavaScript files
└── 404.html # Error page
Key Features
Automatic Route Discovery
- Scans all view files to find available routes
- Excludes private views (prefixed with
_) - Always includes a 404 error page
Intelligent Link Crawling
- Parses HTML content to find internal links
- Follows
hrefandsrcattributes automatically - Only processes same-domain links
- Prevents infinite loops and duplicate processing
File Path Normalization
// Route to file mapping examples
'/' → 'index.html'
'/about' → 'about.html'
'/posts/' → 'posts/index.html'
'/posts/123' → 'posts/123.html'
Content Type Handling
- HTML pages - Saved with
.htmlextension - CSS files - Saved with
.cssextension - JavaScript - Saved with
.jsextension - Other assets - Extension determined by MIME type
Common Use Cases
Blog Deployment
# Clean and rebuild static site
rm -rf build && pinstripe generate-static-site
# Deploy to static hosting
rsync -av build/static/ user@server:/var/www/html/
CI/CD Integration
{
"scripts": {
"build": "pinstripe generate-static-site",
"deploy": "npm run build && aws s3 sync build/static/ s3://my-bucket/"
}
}
Development Preview
# Generate static files for testing
pinstripe generate-static-site
# Serve locally for preview
cd build/static && python3 -m http.server 8000
Related Commands
start-server- Start development server to preview before generatinggenerate-project- Create projects with@pinstripe/static-sitedependencygenerate-view- Add new pages that will be included in static generation