Deployment Guide
This guide covers various ways to deploy your Sherwood-generated static site.
Static Hosting Options
Netlify
Netlify is ideal for JAMstack sites with continuous deployment:
-
Connect Repository:
- Sign up for Netlify account
- Connect your Git repository
- Configure build settings
-
Build Settings:
Build command: cargo run -- generate Publish directory: dist -
Environment Variables: Set
RUST_VERSIONto1.70.0or higher
Vercel
Vercel offers zero-config deployment:
-
Install Vercel CLI:
npm i -g vercel -
Configure Project: Create
vercel.json:{ "buildCommand": "cargo run -- generate", "outputDirectory": "dist", "installCommand": "" } -
Deploy:
vercel --prod
GitHub Pages
Free static hosting for public repositories:
-
Create Workflow:
.github/workflows/deploy.yml:name: Deploy on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable - run: cargo run -- generate - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist -
Enable GitHub Pages:
- Repository Settings → Pages
- Source: GitHub Actions
Cloudflare Pages
Fast CDN-backed static hosting:
- Connect Repository
- Build Settings:
Build command: cargo run -- generate Build output directory: dist - Deploy
Custom Server Deployment
Simple HTTP Server
For development or simple hosting:
# Using Python
cd dist && python -m http.server 8000
# Using Node.js
npx serve dist
# Using Rust basic-server
cargo install basic-http-server
basic-http-server dist
Nginx
Production-grade web server configuration:
server {
listen 80;
server_name example.com;
root /var/www/sherwood/dist;
index index.html;
# Handle clean URLs
location / {
try_files $uri $uri.html $uri/index.html =404;
}
# Cache static assets
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
Apache
Web server configuration:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/sherwood/dist
# Enable clean URLs
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L]
RewriteCond %{REQUEST_FILENAME}/ -d
RewriteRule ^(.*)$ $1/index.html [L]
</VirtualHost>
Build Optimization
Reduce Build Time
For large sites, consider these optimizations:
-
Parallel Processing: Future versions may support parallel markdown processing
-
Selective Rebuild: Only regenerate changed content
-
Asset Optimization:
# Minify CSS npm install -g clean-css-cli find dist -name "*.css" -exec cleancss -o {} {} \; # Optimize images npm install -g imagemin-cli imagemin dist/images/* --out-dir=dist/images
Caching Strategy
Implement proper caching headers:
# HTML files - short cache for content updates
location ~* \.html$ {
expires 1h;
add_header Cache-Control "public, must-revalidate";
}
# Static assets - long cache
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
CI/CD Integration
Docker
Containerized deployment:
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM nginx:alpine
COPY --from=builder /app/target/release/sherwood /usr/local/bin/
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Kubernetes
Deployment manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: sherwood-site
spec:
replicas: 3
selector:
matchLabels:
app: sherwood-site
template:
metadata:
labels:
app: sherwood-site
spec:
containers:
- name: sherwood
image: sherwood-site:latest
ports:
- containerPort: 80
Performance Tips
- Use CDN for static asset delivery
- Enable Gzip/Brotli compression
- Implement proper caching headers
- Optimize images and use modern formats
- Minimize bundle sizes through content optimization
Your Sherwood site is now ready for production deployment!