How to Deploy an Astro Site for Free
Astro builds fast, content-focused websites, and by default it outputs plain static files. That makes it one of the easiest frameworks to host. This guide shows how to deploy an Astro site for free on LaunchPad, with free SSL and a new deploy on every push.
What you need
- An Astro project in a GitHub or GitLab repository.
- A free Hostmargin account.
- A working build:
npm installthennpm run build, which writes the site todist.
Step 1: Set your site address
Astro uses the site setting to build absolute URLs for sitemaps, RSS feeds and canonical links. Set it to the address you'll use:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://your-site.lplive.xyz',
});
If you'll use your own domain, put that here instead. You can change it any time and push again.
Step 2: Create the project
- Sign in at launchpad.hostmargin.com and click New project.
- Choose GitHub or GitLab, paste the repository URL and pick the branch.
- Choose the Astro preset:
| Setting | Value |
|---|---|
| Build command | npm run build |
| Output directory | dist |
Step 3: Deploy
Choose a free subdomain and click Create & Deploy. The live log shows the install and the Astro build. Once it shows Live, your site is online with HTTPS.
Step 4: Publish on every push
Copy the webhook URL and secret from Settings into your repository's webhook settings. Write a new post in Markdown, push, and it's live a minute later.
Good to know
Keep the output static
LaunchPad hosts static files. Astro's default output: 'static' is what you want. Server-rendered pages and API endpoints need an adapter and a running server, so they aren't available on static hosting.
Scheduled posts
Writing a post for a launch? Use Scheduled publishing in Site controls to deploy the latest commit at a set date and time (IST, up to 90 days ahead).
Preview links for clients
Turn on Password protection while the site is being built. Every page then asks for a username and password, and search engines are told not to index it.
Images
Astro's built-in image optimization runs at build time, so the optimized files are part of dist and work on static hosting.
Next steps
- See the Astro section of the docs.
- Add your own domain from the Domains page, with a free certificate issued automatically.
- Compare plans on the compare page.