Deploying to other hosting platforms¶
Publish Silex websites to Netlify, Vercel, AWS, or any static host.
Overview¶
While Silex includes a connector for GitLab Pages, you can publish to any static hosting platform by downloading the built website from your forge and deploying it manually, or by setting up custom CI/CD pipelines.
Two approaches:
- Download the built site from the CI and deploy manually: universal, works everywhere
- Custom CI/CD integration — Automate with platform-specific tools
Prerequisites¶
- Understanding of publication transformers
- Knowledge of your hosting platform's deployment process
- Basic familiarity with Git and CI/CD
Approach 1: Download and manual deployment¶
Silex has no download connector. The build runs on the forge, and the forge keeps the result.
User workflow¶
- Publish the website to GitLab
- In the GitLab project, go to Build → Jobs
- On the most recent
pagesjob marked Passed, click Download artifacts - Extract the zip: the built site is in its
_sitefolder - Upload the content of
_siteto your host
To upload to an FTP or SFTP server on each publication instead, add the upload to build.json. See Publish to your own web host. Silex Desktop can also publish with FTP or SFTP.
Deployment to Netlify¶
After downloading:
- Go to netlify.com
- Create a new site: Add new site → Deploy manually
- Drag and drop the extracted folder, or:
Deployment to Vercel¶
After downloading:
Or push to GitHub and connect the repo to Vercel.
Deployment to AWS S3¶
After downloading, install the AWS CLI, then:
# Configure credentials
aws configure
# Upload to S3
cd _site
aws s3 sync . s3://my-bucket-name --delete
Enable website hosting in S3:
- Bucket → Properties → Static website hosting → Enable
- Index document:
index.html - Error document:
404.html(if available)
Approach 2: Custom CI/CD integration¶
Automate deployment by setting up a CI/CD pipeline on your platform.
Every site published with Git storage includes a build.sh script, generated by Silex from build.json. Running sh build.sh builds the site into _site/ — that's the build command to use on any platform below.
Netlify via Git integration¶
Connect your Silex repository to Netlify:
- Push website source to GitHub/GitLab
- Go to netlify.com
- Add new site → Import an existing project
- Connect your Git provider
- Configure build settings:
- Build command:
sh build.sh - Publish directory:
_site
Or create a netlify.toml:
[build]
command = "sh build.sh"
publish = "_site"
[build.environment]
NODE_VERSION = "18"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
Vercel deployment¶
Push to GitHub and connect Vercel:
- Push website to GitHub
- Go to vercel.com
- Import Project → Select repo
- Configure:
- Build command:
sh build.sh - Output directory:
_site - Deploy
Or use Vercel CLI:
GitHub Pages¶
Publish from a GitHub repository:
- Push website to GitHub (
mainbranch or/docsfolder) - Go to Settings → Pages
- Select source: GitHub Actions or main branch /docs folder
- Optionally add custom domain
If using GitHub Actions, create .github/workflows/deploy.yml:
name: Deploy to GitHub Pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: sh build.sh
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
Cloudflare Pages¶
Deploy via Git or Wrangler CLI.
Via Git:
- Push to GitHub/GitLab
- Go to Cloudflare Pages → Create a project
- Connect Git repo
- Configure:
- Build command:
sh build.sh - Build output directory:
_site - Deploy
Via CLI:
AWS Amplify¶
Deploy from Git:
- Push to GitHub/CodeCommit/GitLab
- Go to AWS Amplify → New app → Host web app
- Connect Git repo
- Configure build settings:
version: 1
frontend:
phases:
build:
commands:
- sh build.sh
artifacts:
baseDirectory: _site
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Redirects and rewrites¶
Many platforms need custom redirect rules. Examples:
Netlify redirects¶
Create _redirects file:
# Redirect /old-page to /new-page
/old-page /new-page 301
# SPA: redirect 404s to index.html
/* /index.html 200
Or use netlify.toml:
[[redirects]]
from = "/old-page"
to = "/new-page"
status = 301
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
Vercel redirects¶
Create vercel.json:
{
"redirects": [
{ "source": "/old/:path*", "destination": "/new/:path*" }
],
"rewrites": [
{ "source": "/:path*", "destination": "/index.html" }
]
}
Custom domain setup¶
All platforms support custom domains. General steps:
- Point your domain's DNS A record to the platform's IP
- In platform settings, add the domain
- Wait for DNS propagation (5-24 hours)
- Enable HTTPS (automatic on most platforms)
Environment variables¶
Pass secrets to build processes:
Netlify:
1. Site settings → Build & deploy → Environment
2. Add variables (e.g., API_KEY=...)
Vercel: 1. Settings → Environment Variables 2. Add variables
GitHub Actions:
1. Settings → Secrets and variables → Actions
2. Add repository secrets
3. Use in workflow: ${{ secrets.MY_SECRET }}
Performance optimization¶
Most platforms offer: - Image optimization - Automatic compression - Caching headers - CDN distribution
Configure in your build:
// Add cache-busting to asset names
config.cmsConfig.cacheBuster = true
// Set cache headers in netlify.toml
[[headers]]
for = "/assets/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.html"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"
Comparing platforms¶
| Platform | Ease | Free tier | Custom domain | Analytics | CDN |
|---|---|---|---|---|---|
| Netlify | Very easy | Yes | Yes | Yes | Yes |
| Vercel | Very easy | Yes | Yes | Yes | Yes |
| GitHub Pages | Easy | Yes | Yes (with Pro) | Via 3rd party | Yes |
| Cloudflare Pages | Easy | Yes | Yes | Via Analytics | Yes |
| AWS Amplify | Medium | Free tier | Yes | Via CloudWatch | Yes |
| AWS S3 + CloudFront | Medium | No | Yes | Via CloudTrail | Yes |
See also¶
- Publication transformers — Custom publication hooks
- Customize the build — build.json and the publication build
- Hosting connectors — Built-in hosting connectors
- Netlify docs
- Vercel docs
- Cloudflare Pages docs