Skip to content

Deployment

Goal: Deploy to Netlify in 5 minutes.

Deploy your Astro Swiss Theme site to production in minutes. These deployment instructions work for both the free starter theme and the paid version.

Terminal window
npm run build

This creates an optimized production build in the dist/ folder.

Before deploying, test your production build:

Terminal window
npm run preview

Visit http://localhost:4321 to preview the built site.

The build process:

  1. ✅ Compiles TypeScript to JavaScript
  2. ✅ Optimizes and bundles CSS
  3. ✅ Minifies HTML
  4. ✅ Optimizes images
  5. ✅ Generates static routes for all languages
  6. ✅ Creates sitemap (if configured)

Output structure:

dist/
├── index.html # French homepage (default locale)
├── de/
│ └──index.html # German homepage
├── _astro/ # Bundled CSS and JS
├── fonts/ # Font files
└── favicon.svg

Why Netlify?

  • Simple configuration
  • Automatic HTTPS & CDN
  • GitHub integration
  • Free tier available
  1. Create netlify.toml in project root:

    netlify.toml
    [build]
    command = "npm run build"
    publish = "dist"
    [[redirects]]
    from = "/*"
    to = "/index.html"
    status = 200
  2. Deploy:

    • Via Dashboard: Go to netlify.com and import your repository
    • Via CLI:
      Terminal window
      npm install -g netlify-cli
      netlify deploy --prod

Vercel auto-detects Astro projects - no configuration file needed:

  1. Go to vercel.com and import your GitHub repository
  2. Vercel automatically configures build settings
  3. Click “Deploy”

Or use CLI:

Terminal window
npm i -g vercel
vercel

Variables prefixed with PUBLIC_ are available in client-side code.

Create .env file:

.env
PUBLIC_SITE_URL=https://yourdomain.com
PUBLIC_GA_ID=G-XXXXXXXXXX

Use in components:

---
const siteUrl = import.meta.env.PUBLIC_SITE_URL;
---
<meta property="og:url" content={siteUrl} />

Variables without PUBLIC_ prefix are only available server-side.

.env
API_KEY=secret-key-here
DATABASE_URL=postgres://...

Add variables in Project Settings → Environment Variables



  1. Go to Project Settings → Domains
  2. Add your domain
  3. Update DNS records as instructed