Deployment Strategies
Verdocs makes deployment seamless by offering host-specific optimizations. Once you've written your documentation, you can generate a production-ready out/ directory tailored for your hosting provider.
The --host Flag
The verdocs generate command includes a --host flag that automatically configures the output directory for your target platform:
verdocs generate --host <vps | vercel | gh-pages>
1. Personal VPS (Nginx/Apache)
Hosting on a VPS gives you full control over your documentation. By using --host vps, Verdocs ensures that visiting your root domain automatically redirects to the latest documentation version.
Steps to Deploy
- Generate the site:
verdocs generate --host vps - Upload the files:
Copy the contents of the
out/directory to your server's web root (e.g.,/var/www/docs):scp -r out/* user@your-vps-ip:/var/www/docs - Configure Nginx:
Ensure your site configuration handles folder-based routing:
server { listen 80; server_name docs.yourdomain.com; root /var/www/docs; index index.html; location / { # Standard static file serving with .html fallback try_files $uri $uri/ $uri.html =404; } } - Restart Nginx:
sudo systemctl restart nginx
2. Caddy (Modern VPS)
Caddy is a powerful, enterprise-ready open source web server with automatic HTTPS. Serving a Verdocs site with Caddy requires minimal configuration.
Steps to Deploy
- Generate the site:
verdocs generate --host vps - Upload the files:
Transfer the
out/directory content to your server (e.g.,/var/www/docs). - Configure Caddy:
Create or update your
Caddyfile:docs.yourdomain.com { root * /var/www/docs file_server # Handle clean URLs (e.g., /v1.0.0/home -> /v1.0.0/home.html) try_files {path} {path}/ {path}.html } - Restart Caddy:
sudo systemctl reload caddy
3. Vercel
Vercel is optimized for speed and global delivery. Using --host vercel automatically generates the required configuration for clean routing.
Steps to Deploy
- Generate the site:
verdocs generate --host vercel - Deploy via CLI:
Verdocs automatically creates avercel out --prodvercel.jsonfile insideout/withcleanUrls: true, so no manual configuration is needed.
3. GitHub Pages
Perfect for hosting documentation directly from your repository. Using --host gh-pages handles the specific requirements of GitHub's environment.
Steps to Deploy
- Configure Base Path:
If your site is at
username.github.io/repo-name/, setbase_path: /repo-name/in yourconfig.yml. - Generate the site:
verdocs generate --host gh-pages - Push to Branch:
Push the contents of the
out/folder to yourgh-pagesbranch. Verdocs automatically creates a.nojekyllfile to ensure all documentation folders are served correctly.
4. Docker
If you prefer containerized deployment, you can wrap the output in a lightweight Nginx container.
- Generate:
verdocs generate --host vps - Dockerfile:
FROM nginx:alpine COPY ./out /usr/share/nginx/html EXPOSE 80 - Build and Run:
docker build -t my-docs . docker run -p 80:80 my-docs