🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Astro Themes••By Komal Nakrani

Astro Landing Page Tutorial: Build One Step by Step

An Astro landing page tutorial: set up the project, build hero, features, pricing and FAQ sections as components, add a signup form, optimize images and deploy.

#Astro#Landing Page#Tutorial#Tailwind CSS

This Astro landing page tutorial builds a complete, fast product landing page: a layout with SEO tags, hero, features, pricing, FAQ and signup sections as separate components, content kept in one data file, optimized images, and a static build you can deploy anywhere. Astro suits landing pages because it ships zero JavaScript by default, so the page is plain HTML and CSS that loads quickly on any connection.

Key Takeaways

  • Build each section as its own .astro component and assemble them in src/pages/index.astro.
  • Keep copy, features and prices in one data file so non-developers can edit them safely.
  • Use <Image /> from astro:assets for the hero image to get resized, lazy-loaded WebP output.
  • A signup form needs no JavaScript framework; a plain HTML form posting to a form service works.
  • The finished page is static HTML in dist/, ready for Cloudflare Pages, Netlify or Vercel.

What you will build

A single-page site for a fictional product called “Beacon”, with these sections in order: navigation, hero with a primary call to action, a logo or proof strip, three feature blocks, a pricing table, an FAQ and a final signup form. Every section is a component, styled with Tailwind CSS, and the whole page ships no client JavaScript except one tiny script for the mobile menu.

Step 1: Create the project and add Tailwind

npm create astro@latest beacon-landing -- --template minimal
cd beacon-landing
npx astro add tailwind
npm run dev

astro add tailwind installs Tailwind CSS 4 and its Vite plugin and creates a global stylesheet. Make sure it contains the import and your brand tokens:

/* src/styles/global.css */
@import "tailwindcss";

@theme {
  --color-brand: #4f46e5;
  --color-brand-dark: #3730a3;
  --font-sans: "Inter", system-ui, sans-serif;
}

Prefer plain CSS? Astro’s scoped <style> blocks work just as well; the Tailwind vs CSS comparison covers when each makes sense.

Step 2: Create a layout with SEO tags

The layout holds the <head>, so every page gets a title, description, canonical URL and social tags.

---
// src/layouts/Base.astro
import '../styles/global.css';

interface Props {
  title: string;
  description: string;
  image?: string;
}

const { title, description, image = '/og.png' } = Astro.props;
const canonical = new URL(Astro.url.pathname, Astro.site);
const ogImage = new URL(image, Astro.site);
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{title}</title>
    <meta name="description" content={description} />
    <link rel="canonical" href={canonical} />
    <meta property="og:title" content={title} />
    <meta property="og:description" content={description} />
    <meta property="og:image" content={ogImage} />
    <meta name="twitter:card" content="summary_large_image" />
  </head>
  <body class="bg-white font-sans text-zinc-900 antialiased">
    <slot />
  </body>
</html>

Set site: 'https://beacon.example.com' in astro.config.mjs so Astro.site is defined. The Astro SEO guide goes further with structured data and sitemaps.

Step 3: Put the content in one data file

Landing page copy changes often. Keeping it in one typed file means editing the headline or a price never requires touching markup.

// src/data/landing.ts
export const hero = {
  eyebrow: 'Uptime monitoring for small teams',
  title: 'Know your site is down before your customers do',
  subtitle: 'Beacon checks every page each minute and alerts you by email, Slack or SMS.',
  cta: { label: 'Start free trial', href: '#signup' },
};

export const features = [
  { title: 'One-minute checks', body: 'HTTP, keyword and SSL checks from multiple regions.' },
  { title: 'Alerts that reach you', body: 'Email, Slack and SMS with escalation rules.' },
  { title: 'Status pages', body: 'A public page your customers can bookmark.' },
];

export const plans = [
  { name: 'Starter', price: 9, features: ['10 monitors', 'Email alerts'], featured: false },
  { name: 'Team', price: 29, features: ['50 monitors', 'Slack and SMS', 'Status page'], featured: true },
];

export const faqs = [
  { q: 'Is there a free trial?', a: 'Yes, 14 days with every feature and no card required.' },
  { q: 'Can I cancel any time?', a: 'Yes. Plans are monthly and you can cancel from settings.' },
];

Step 4: Build the hero section

The hero is the most important block: a clear headline, one sentence of value, one primary action and a product image.

---
// src/components/Hero.astro
import { Image } from 'astro:assets';
import screenshot from '../assets/dashboard.png';
import { hero } from '../data/landing';
---
<section class="mx-auto grid max-w-6xl items-center gap-12 px-6 py-20 md:grid-cols-2">
  <div>
    <p class="text-sm font-semibold uppercase tracking-wide text-brand">{hero.eyebrow}</p>
    <h1 class="mt-3 text-4xl font-bold tracking-tight md:text-5xl">{hero.title}</h1>
    <p class="mt-5 text-lg text-zinc-600">{hero.subtitle}</p>
    <a href={hero.cta.href} class="mt-8 inline-block rounded-lg bg-brand px-6 py-3 font-semibold text-white hover:bg-brand-dark">
      {hero.cta.label}
    </a>
  </div>
  <Image
    src={screenshot}
    alt="Beacon dashboard showing uptime for five websites"
    widths={[480, 768, 1200]}
    sizes="(min-width: 768px) 50vw, 100vw"
    loading="eager"
    fetchpriority="high"
    class="rounded-xl shadow-xl"
  />
</section>

The hero image is usually the Largest Contentful Paint element, so it loads eagerly with high priority. Every other image on the page should keep the default lazy loading. <Image /> resizes the PNG at build time and outputs WebP with width and height set, which prevents layout shift. The responsive images tip explains widths and sizes.

Step 5: Features and pricing sections

Both map over the data file.

---
// src/components/Features.astro
import { features } from '../data/landing';
---
<section id="features" class="bg-zinc-50 py-20">
  <div class="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-3">
    {features.map((f) => (
      <article class="rounded-xl bg-white p-6 shadow-sm">
        <h2 class="text-lg font-semibold">{f.title}</h2>
        <p class="mt-2 text-zinc-600">{f.body}</p>
      </article>
    ))}
  </div>
</section>
---
// src/components/Pricing.astro
import { plans } from '../data/landing';
---
<section id="pricing" class="mx-auto max-w-4xl px-6 py-20">
  <h2 class="text-center text-3xl font-bold">Simple pricing</h2>
  <div class="mt-10 grid gap-6 md:grid-cols-2">
    {plans.map((plan) => (
      <article class:list={['rounded-2xl border p-8', plan.featured ? 'border-brand ring-2 ring-brand' : 'border-zinc-200']}>
        <h3 class="text-lg font-semibold">{plan.name}</h3>
        <p class="mt-4 text-4xl font-bold">${plan.price}<span class="text-base font-normal text-zinc-500">/month</span></p>
        <ul class="mt-6 space-y-2 text-zinc-600">
          {plan.features.map((item) => <li>{item}</li>)}
        </ul>
      </article>
    ))}
  </div>
</section>

class:list is Astro’s built-in helper for conditional classes, so the featured plan gets a ring without any JavaScript.

Step 6: An FAQ with zero JavaScript

Native <details> and <summary> elements give you an accessible accordion for free.

---
// src/components/Faq.astro
import { faqs } from '../data/landing';
---
<section id="faq" class="mx-auto max-w-3xl px-6 py-20">
  <h2 class="text-3xl font-bold">Questions</h2>
  <div class="mt-8 divide-y divide-zinc-200">
    {faqs.map((item) => (
      <details class="group py-4">
        <summary class="cursor-pointer font-semibold">{item.q}</summary>
        <p class="mt-2 text-zinc-600">{item.a}</p>
      </details>
    ))}
  </div>
</section>

If you want FAQ rich results, add FAQPage structured data generated from the same array; the FAQ section with schema guide shows how.

Step 7: Add a signup form

A static landing page can still collect emails. Post a normal HTML form to your email provider’s form endpoint or a form service, and it works without any client-side code.

---
// src/components/Signup.astro
const action = import.meta.env.PUBLIC_SIGNUP_ENDPOINT;
---
<section id="signup" class="bg-brand py-20 text-white">
  <div class="mx-auto max-w-xl px-6 text-center">
    <h2 class="text-3xl font-bold">Start your free trial</h2>
    <form method="post" action={action} class="mt-8 flex flex-col gap-3 sm:flex-row">
      <label for="email" class="sr-only">Email address</label>
      <input id="email" name="email" type="email" required autocomplete="email"
        placeholder="[email protected]" class="flex-1 rounded-lg px-4 py-3 text-zinc-900" />
      <button type="submit" class="rounded-lg bg-zinc-900 px-6 py-3 font-semibold">Get started</button>
    </form>
  </div>
</section>

On Netlify you can use Netlify Forms by adding a data-netlify="true" attribute and a name to the form instead. If you need server-side validation, Astro Actions handle form posts on an on-demand route. The newsletter signup tip covers provider-specific setups.

Step 8: Assemble the page

---
// src/pages/index.astro
import Base from '../layouts/Base.astro';
import Nav from '../components/Nav.astro';
import Hero from '../components/Hero.astro';
import Features from '../components/Features.astro';
import Pricing from '../components/Pricing.astro';
import Faq from '../components/Faq.astro';
import Signup from '../components/Signup.astro';
---
<Base
  title="Beacon: Uptime Monitoring for Small Teams"
  description="Beacon checks every page each minute and alerts you by email, Slack or SMS. Start a free 14-day trial."
>
  <Nav />
  <main>
    <Hero />
    <Features />
    <Pricing />
    <Faq />
    <Signup />
  </main>
</Base>

Reordering sections, or testing a variant page at src/pages/v2.astro, is now a matter of moving component tags.

Step 9: Check performance and deploy

npm run build
npm run preview

Run Lighthouse against the preview URL. Things to check on a landing page:

  1. The hero image is the LCP element and loads with fetchpriority="high".
  2. No unused fonts: load one family with two weights, preferably self-hosted.
  3. Third-party scripts (chat, analytics) are deferred or loaded after interaction.

Deploy the dist/ folder to Cloudflare Pages, Netlify or Vercel by connecting the repository with npm run build as the build command. The Cloudflare Pages deploy docs walk through the setup. For more on Astro’s defaults, see the official Astro images guide.

Starting from a template instead

Building from scratch is the best way to learn, but a finished landing page template saves most of a day on design and responsive details. Free options include Astro’s official starters on astro.build/themes and community themes such as AstroWind. Komal Nakrani’s launch and coming soon category is small (it currently holds the Crafters theme), and most product landing designs sit in the larger technology category.

FAQ

Is Astro good for landing pages?

Yes. Astro outputs static HTML with no JavaScript by default, which gives landing pages fast load times and good Core Web Vitals. You can still add interactive pieces, such as a pricing toggle, as islands with client:* directives only where needed.

How do I add a contact or signup form to a static Astro landing page?

Use a plain HTML form that posts to a form service, your email provider’s signup endpoint, or Netlify Forms. No framework or server code is required. For server-side validation, use Astro Actions or an API endpoint on an on-demand rendered route with an adapter.

Can I build an Astro landing page without Tailwind?

Yes. Astro scopes the <style> block in each component automatically, so plain CSS works without class name conflicts. Tailwind is optional and mainly speeds up building many sections with a consistent spacing and color scale.

How do I A/B test an Astro landing page?

The simplest approach is two static pages, such as / and /v2/, with traffic split by your host or ad platform. For per-visitor splitting on one URL, use your host’s edge features or Astro middleware on an on-demand route.

How long does it take to build a landing page with Astro?

Following this tutorial, a developer can build and deploy a basic landing page in a few hours. Most time goes into copy and design rather than code. Starting from a template shortens that to customizing text, colors and images.