🔥 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

Build a Restaurant Website with Astro: Step by Step

Build a restaurant website with Astro: an editable menu in YAML, opening hours, reservations, a lazy map, Restaurant structured data, fast photos and free static hosting.

#Astro#Restaurant Website#Local SEO#Tutorial

To build a restaurant website with Astro, keep the menu, opening hours and contact details in simple data files, render them into a fast static site with a home page, menu page, reservations link and location section, and add Restaurant structured data so search engines understand your address, hours and cuisine. The finished site is plain HTML that loads quickly on a phone, which is where most diners look you up.

Key Takeaways

  • Diners want four things fast: the menu, opening hours, location and a way to book. Put all four within one tap of the home page.
  • Store the menu in a YAML file loaded with Astro’s file() loader, so staff can edit prices without touching markup.
  • Serve the menu as HTML, not a PDF; it is faster, accessible and indexable.
  • Add Restaurant JSON-LD with address, hours and menu URL for local search.
  • Lazy-load the map embed so it doesn’t slow the first screen.

What a restaurant website needs

Most restaurant visits come from a phone, often from a search like “restaurant near me” or the restaurant’s name. Visitors want answers, not a long scroll. Plan these pages:

  1. Home: name, one photo, one line about the food, hours today, “Book a table” and “View menu”.
  2. Menu: grouped by section, with prices and dietary labels.
  3. Visit: address, map, hours, parking and accessibility notes.
  4. Book: a link or embed for your reservation provider, plus phone number.
  5. Optional: private dining, events, gift cards, press.

Create the project:

npm create astro@latest trattoria -- --template minimal
cd trattoria
npm run dev

Put the restaurant details in one file

Name, address, phone and hours appear in the header, footer, visit page and structured data. Keep them in one place.

// src/data/restaurant.ts
export const restaurant = {
  name: 'Trattoria Lume',
  cuisine: 'Italian',
  phone: '+1-555-0142',
  email: '[email protected]',
  address: {
    street: '18 Harbour Street',
    city: 'Portland',
    region: 'ME',
    postalCode: '04101',
    country: 'US',
  },
  hours: [
    { days: ['Tuesday', 'Wednesday', 'Thursday'], opens: '17:00', closes: '22:00' },
    { days: ['Friday', 'Saturday'], opens: '17:00', closes: '23:00' },
    { days: ['Sunday'], opens: '12:00', closes: '21:00' },
  ],
  bookingUrl: 'https://booking.example.com/trattoria-lume',
};

Load the menu with a Content Collection

A menu is structured data: sections, items, descriptions, prices and labels. YAML is easy for non-developers to edit, and Astro’s file() loader reads it into a typed collection.

# src/data/menu.yaml
- id: antipasti
  title: Antipasti
  order: 1
  items:
    - name: Burrata
      description: Heirloom tomatoes, basil oil, grilled bread
      price: 14
      tags: [vegetarian]
    - name: Fritto misto
      description: Squid, shrimp, lemon aioli
      price: 16
- id: pasta
  title: Pasta
  order: 2
  items:
    - name: Cacio e pepe
      description: Tonnarelli, pecorino, black pepper
      price: 19
      tags: [vegetarian]
    - name: Ragù alla bolognese
      description: Slow-cooked beef and pork, tagliatelle
      price: 23
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { file } from 'astro/loaders';
import { z } from 'astro/zod';

const menu = defineCollection({
  loader: file('src/data/menu.yaml'),
  schema: z.object({
    title: z.string(),
    order: z.number(),
    items: z.array(
      z.object({
        name: z.string(),
        description: z.string().optional(),
        price: z.number(),
        tags: z.array(z.enum(['vegetarian', 'vegan', 'gluten-free', 'spicy'])).default([]),
      })
    ),
  }),
});

export const collections = { menu };

The schema catches mistakes before they reach the site. A typo like vegitarian or a price written as "14 dollars" fails the build with a clear message instead of publishing a broken menu. The Content Collections guide explains loaders and schemas in more depth.

Build the menu page

---
// src/pages/menu.astro
import { getCollection } from 'astro:content';
import Base from '../layouts/Base.astro';

const sections = (await getCollection('menu')).sort((a, b) => a.data.order - b.data.order);
const price = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 0 });
---
<Base title="Menu | Trattoria Lume" description="Our dinner menu: antipasti, fresh pasta, mains and desserts, with vegetarian and gluten-free options.">
  <h1>Menu</h1>
  <nav aria-label="Menu sections">
    {sections.map((s) => <a href={`#${s.id}`}>{s.data.title}</a>)}
  </nav>

  {sections.map((section) => (
    <section id={section.id}>
      <h2>{section.data.title}</h2>
      <ul class="menu-list">
        {section.data.items.map((item) => (
          <li>
            <div class="row">
              <h3>{item.name}</h3>
              <span class="price">{price.format(item.price)}</span>
            </div>
            {item.description && <p>{item.description}</p>}
            {item.tags.length > 0 && <p class="tags">{item.tags.join(' · ')}</p>}
          </li>
        ))}
      </ul>
    </section>
  ))}
</Base>

<style>
  .menu-list { list-style: none; padding: 0; display: grid; gap: 1.25rem; }
  .row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
  .price { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .tags { font-size: 0.85rem; color: var(--muted); text-transform: capitalize; }
</style>

An HTML menu loads instantly, scales on any screen, works with screen readers and can be found in search. If you also want a printable version, link a PDF as a secondary option.

Show opening hours and today’s status

Hours are the most checked piece of information. Render them from the data file and highlight today on the client with a tiny script, since a static build doesn’t know what day the visitor is reading it.

---
// src/components/Hours.astro
import { restaurant } from '../data/restaurant';
const week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
const rows = week.map((day) => {
  const slot = restaurant.hours.find((h) => h.days.includes(day));
  return { day, text: slot ? `${slot.opens}–${slot.closes}` : 'Closed' };
});
---
<table class="hours">
  <caption>Opening hours</caption>
  <tbody>
    {rows.map((r) => (
      <tr data-day={r.day}>
        <th scope="row">{r.day}</th>
        <td>{r.text}</td>
      </tr>
    ))}
  </tbody>
</table>

<script>
  const today = new Date().toLocaleDateString('en-US', { weekday: 'long' });
  document.querySelector(`.hours tr[data-day="${today}"]`)?.classList.add('today');
</script>

<style>
  .today { font-weight: 700; }
</style>

Reservations and contact

Most restaurants use a booking provider. Link to it with a clear button, and always show the phone number as a tel: link for people who prefer to call.

---
// src/components/BookCta.astro
import { restaurant } from '../data/restaurant';
---
<div class="book">
  <a class="button" href={restaurant.bookingUrl} rel="noopener">Book a table</a>
  <a href={`tel:${restaurant.phone}`}>Call {restaurant.phone}</a>
</div>

If the provider offers an embeddable widget, put it on /book/ only, not on every page, so its script doesn’t slow the rest of the site. For catering or private dining enquiries, a plain HTML form posting to a form service keeps the site static.

Add a lazy-loaded map

A map embed is heavy. Show it only when it is near the viewport by using an iframe with loading="lazy", plus a plain text address and a directions link that work without it.

---
// src/components/Location.astro
import { restaurant } from '../data/restaurant';
const { street, city, region, postalCode } = restaurant.address;
const query = encodeURIComponent(`${restaurant.name}, ${street}, ${city}`);
---
<section id="visit">
  <h2>Visit us</h2>
  <address>{street}<br />{city}, {region} {postalCode}</address>
  <a href={`https://www.google.com/maps/search/?api=1&query=${query}`}>Get directions</a>
  <iframe
    title={`Map showing ${restaurant.name}`}
    src={`https://www.google.com/maps?q=${query}&output=embed`}
    width="600"
    height="400"
    loading="lazy"
    referrerpolicy="no-referrer-when-downgrade"
    style="border:0;width:100%"
  ></iframe>
</section>

Structured data tells search engines your cuisine, address, hours, phone and menu URL. Generate it from the same data file so it never drifts from what the page shows.

---
// src/components/RestaurantSchema.astro
import { restaurant } from '../data/restaurant';
const site = Astro.site?.toString() ?? '/';
const schema = {
  '@context': 'https://schema.org',
  '@type': 'Restaurant',
  name: restaurant.name,
  servesCuisine: restaurant.cuisine,
  telephone: restaurant.phone,
  url: site,
  menu: new URL('/menu/', site).toString(),
  acceptsReservations: true,
  address: {
    '@type': 'PostalAddress',
    streetAddress: restaurant.address.street,
    addressLocality: restaurant.address.city,
    addressRegion: restaurant.address.region,
    postalCode: restaurant.address.postalCode,
    addressCountry: restaurant.address.country,
  },
  openingHoursSpecification: restaurant.hours.map((h) => ({
    '@type': 'OpeningHoursSpecification',
    dayOfWeek: h.days,
    opens: h.opens,
    closes: h.closes,
  })),
};
---
<script type="application/ld+json" set:html={JSON.stringify(schema)} />

Include it in the layout’s <head> on the home page. Pair it with a claimed Google Business Profile that uses the same name, address and phone number. The Astro SEO guide covers titles, canonical URLs and sitemaps.

Food photos without the weight

Photos sell the food, and they are usually the heaviest part of a restaurant site. Store them in src/assets/ and render them with <Image /> so Astro resizes and converts them at build time:

---
// src/components/Hero.astro
import { Image } from 'astro:assets';
import dish from '../assets/cacio-e-pepe.jpg';
---
<Image src={dish} alt="Cacio e pepe in a white bowl" widths={[480, 960, 1440]} sizes="100vw" loading="eager" fetchpriority="high" />

Use one large hero photo and lazy-load the gallery. The responsive images tip explains widths and sizes.

Deploy and keep it updated

Run npm run build and deploy dist/ to Cloudflare Pages, Netlify or Vercel, all of which host static sites for free at restaurant traffic levels. Connect the Git repository so editing menu.yaml on GitHub and committing triggers a new build. If the owner doesn’t want to use GitHub, a git-based CMS can give them a form to edit the menu file. See the static deploy docs and the official Astro Content Collections reference for the file() loader.

Using a restaurant template

If you want a finished design to customize, the food and drink category holds Komal Nakrani’s restaurant, cafe and bar themes. One example is Amber, a one-page template for restaurants and cafes with the essential sections already laid out. Free community starters on astro.build/themes are another option if budget is tight.

FAQ

What pages should a restaurant website have?

At minimum: a home page with hours and a booking button, a menu page, and a visit or contact page with address, map and phone. Add private dining, events or gift card pages if you offer them. Keep the menu, hours and booking within one tap from the home page on mobile.

Should a restaurant menu be a PDF or a web page?

A web page. HTML menus load faster on phones, resize to any screen, work with screen readers, and can be indexed by search engines. You can still offer a PDF download for printing as a secondary link.

How do I update the menu on an Astro restaurant site?

Edit the menu data file, such as src/data/menu.yaml, and commit the change. If the site is connected to Cloudflare Pages, Netlify or Vercel, the commit triggers a rebuild and the new menu is live in a minute or two. A git-based CMS can give non-technical staff a form for the same file.

Do restaurant websites need structured data?

It helps. Restaurant structured data with address, hours, cuisine, phone and menu URL helps search engines understand the business and show accurate details. Generate it from the same data the page displays, and keep it consistent with your Google Business Profile.

How much does it cost to host an Astro restaurant website?

A static Astro site can be hosted for free on Cloudflare Pages, Netlify or Vercel for typical restaurant traffic. The ongoing costs are usually only the domain name and any reservation or online ordering service you use.