🔥 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

Local SEO for Astro: A Practical Guide for Business Sites

Local SEO for Astro business sites: consistent NAP, location pages from a content collection, LocalBusiness JSON-LD, fast maps and a Google Business Profile.

#Astro#Local SEO#SEO#JSON-LD#Small Business

Local SEO for Astro comes down to five jobs: keep your business name, address and phone number (NAP) identical everywhere, give every location or service area its own page, add LocalBusiness structured data, keep the pages fast on mobile, and connect the site to a verified Google Business Profile. Astro handles the technical half well because it ships complete HTML with no JavaScript by default; the rest is content and consistency.

This guide shows how to build each piece into an Astro 7 site, with code for a single-location shop and a multi-location business.

Key Takeaways

  • Store NAP and opening hours in one data file and render them everywhere from it, so they never drift.
  • Build one page per location or service area from a content collection with getStaticPaths().
  • Generate LocalBusiness JSON-LD from the same data, and never mark up reviews you collected yourself.
  • Lazy-load maps or replace them with a “Get directions” link to protect mobile speed.
  • Your Google Business Profile drives the map results; the website supports it with matching facts.

What local SEO means for an Astro site

Local search results have two parts: the map pack (driven mostly by your Google Business Profile) and the regular organic results below it. Google describes local ranking as a mix of relevance, distance and prominence. Your website feeds relevance and prominence: it confirms what you do, where you are, and that the details on your profile are real.

For a site built with Astro, that translates into a short checklist:

Signal Where it lives Astro piece
Consistent NAP Footer, contact page, location pages One business.ts data module
Location relevance /locations/<city>/ pages Content collection + getStaticPaths()
Structured data <head> of each location page JSON-LD built from the same data
Mobile speed Every page Static HTML, lazy maps, optimized images
Crawlability Whole site @astrojs/sitemap, clean URLs
Profile link Google Business Profile Website URL points to the matching location page

None of this needs a server. A static Astro build on any host covers all of it.

Keep NAP in one place

The most common local SEO problem isn’t a missing tag. It’s a phone number written three different ways across the footer, contact page and directory listings. Put the canonical facts in one module and import it wherever they appear:

// src/data/business.ts
export const business = {
  name: 'Northside Plumbing',
  phone: '+1-555-010-2040',
  phoneDisplay: '(555) 010-2040',
  email: '[email protected]',
  url: 'https://northsideplumbing.example',
  address: {
    street: '412 Mill Road',
    city: 'Springfield',
    region: 'IL',
    postalCode: '62701',
    country: 'US',
  },
  hours: [
    { days: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], opens: '08:00', closes: '18:00' },
    { days: ['Saturday'], opens: '09:00', closes: '13:00' },
  ],
} as const;

Then render it in a small component with semantic markup. The <address> element and a tel: link help both people and parsers:

---
// src/components/NapBlock.astro
import { business } from '../data/business';
const { address: a } = business;
---
<address class="nap">
  <strong>{business.name}</strong><br />
  {a.street}<br />
  {a.city}, {a.region} {a.postalCode}<br />
  <a href={`tel:${business.phone}`}>{business.phoneDisplay}</a>
</address>

Use exactly the same name and address format on your Google Business Profile, Bing Places, Apple Business Connect and the main directories in your industry. If you move or change numbers, edit business.ts, rebuild, and update the listings the same day.

Build location and service-area pages

A business with several branches, or one branch that serves several towns, needs a page per place. Each page should carry real local detail: the address or area covered, hours, the services offered there, parking or access notes, and photos of the actual premises. Pages that only swap the city name in otherwise identical text are thin content and rarely rank.

Model locations as a content collection. The file() loader reads a JSON array, so non-developers can edit one file:

// src/content.config.ts
import { defineCollection } from 'astro:content';
import { file } from 'astro/loaders';
import { z } from 'astro/zod';

const locations = defineCollection({
  loader: file('src/data/locations.json'),
  schema: z.object({
    city: z.string(),
    street: z.string(),
    region: z.string(),
    postalCode: z.string(),
    phone: z.string(),
    lat: z.number(),
    lng: z.number(),
    services: z.array(z.string()),
    intro: z.string(),
    mapsUrl: z.url(),
  }),
});

export const collections = { locations };
[
  {
    "id": "springfield",
    "city": "Springfield",
    "street": "412 Mill Road",
    "region": "IL",
    "postalCode": "62701",
    "phone": "+1-555-010-2040",
    "lat": 39.7817,
    "lng": -89.6501,
    "services": ["Emergency repairs", "Water heaters", "Drain cleaning"],
    "intro": "Our original branch, two blocks from the Mill Road fire station, with customer parking at the rear.",
    "mapsUrl": "https://maps.app.goo.gl/example"
  }
]

The id field becomes the entry ID and the URL segment. Generate one page per entry:

---
// src/pages/locations/[id].astro
import { getCollection } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
import LocalSchema from '../../components/LocalSchema.astro';

export async function getStaticPaths() {
  const locations = await getCollection('locations');
  return locations.map((location) => ({ params: { id: location.id }, props: { location } }));
}

const { location } = Astro.props;
const l = location.data;
---
<BaseLayout
  title={`Plumber in ${l.city}, ${l.region}`}
  description={`Northside Plumbing in ${l.city}: ${l.services.join(', ')}. Call ${l.phone}.`}
>
  <LocalSchema slot="head" location={location} />
  <h1>Plumber in {l.city}</h1>
  <p>{l.intro}</p>
  <h2>Services in {l.city}</h2>
  <ul>{l.services.map((s) => <li>{s}</li>)}</ul>
  <address>
    {l.street}, {l.city}, {l.region} {l.postalCode}<br />
    <a href={`tel:${l.phone}`}>{l.phone}</a>
  </address>
  <a href={l.mapsUrl}>Get directions</a>
</BaseLayout>

The title pattern “service in city” matches how people search locally. Link every location page from a /locations/ index and from the footer, so none of them are orphaned. The Content Collections docs page covers the loader and schema options in more depth.

Add LocalBusiness structured data

Structured data tells search engines which text on the page is the business name, the address and the hours. Build it from the same collection entry so it can never disagree with the visible content:

---
// src/components/LocalSchema.astro
import type { CollectionEntry } from 'astro:content';
import { business } from '../data/business';

interface Props { location: CollectionEntry<'locations'> }
const l = Astro.props.location.data;

const schema = {
  '@context': 'https://schema.org',
  '@type': 'Plumber',
  name: `${business.name} ${l.city}`,
  url: new URL(Astro.url.pathname, Astro.site).href,
  telephone: l.phone,
  address: {
    '@type': 'PostalAddress',
    streetAddress: l.street,
    addressLocality: l.city,
    addressRegion: l.region,
    postalCode: l.postalCode,
    addressCountry: business.address.country,
  },
  geo: { '@type': 'GeoCoordinates', latitude: l.lat, longitude: l.lng },
  openingHoursSpecification: business.hours.map((h) => ({
    '@type': 'OpeningHoursSpecification',
    dayOfWeek: h.days,
    opens: h.opens,
    closes: h.closes,
  })),
};
---
<script type="application/ld+json" set:html={JSON.stringify(schema)} />

Use the most specific LocalBusiness subtype that fits (Plumber, Dentist, Restaurant, HairSalon and so on). Validate pages with Google’s Rich Results Test, and read Google’s local business structured data guidelines for required properties. Our full LocalBusiness schema guide covers subtypes, multiple departments and sameAs links.

One rule to remember: Google does not show review stars for reviews a business collects and displays about itself on its own site. Don’t add aggregateRating to your LocalBusiness markup expecting stars. Ask customers to review you on your Google Business Profile instead.

Keep local pages fast on mobile

Most local searches happen on phones, often on mobile data. Astro gives you a head start because a page without client:* directives ships no JavaScript. The usual things that slow local business sites down are third-party embeds:

  • Maps. A Google Maps iframe pulls in a large amount of script. Use loading="lazy", load the map only after a click, or replace it with a “Get directions” link.
  • Review widgets. Most load a script on every page. Show two or three quoted reviews as plain HTML and link to the profile.
  • Booking tools. Load them on the booking page only, not site-wide.
  • Hero images. Use <Image /> from astro:assets with explicit width and height so the photo is resized and doesn’t shift the layout.
---
// src/components/StoreMap.astro
interface Props { query: string; title: string }
const { query, title } = Astro.props;
const src = `https://www.google.com/maps?q=${encodeURIComponent(query)}&output=embed`;
---
<iframe
  src={src}
  title={title}
  width="600"
  height="400"
  loading="lazy"
  referrerpolicy="no-referrer-when-downgrade"
  style="border:0; width:100%; height:auto; aspect-ratio:3/2"
></iframe>

With loading="lazy", the browser doesn’t fetch the map until it’s close to the viewport, so a map in the footer costs nothing on first load. Check the result with PageSpeed Insights; our Core Web Vitals guide explains what to fix if LCP or INP is slow.

Technical basics that still matter

Local pages are still pages. Make sure the general SEO setup is done:

  1. Set site in astro.config.mjs so canonical URLs and the sitemap use your real domain.
  2. Add @astrojs/sitemap so every location page is listed. The Astro sitemap tip shows the setup.
  3. Give each location page a unique title and description that names the service and the town.
  4. Use one URL format (with or without trailing slash) and keep it consistent in links and canonicals.
  5. Add the business phone and city to the footer, rendered from business.ts.

Our Astro SEO checklist covers the rest, including the head component, robots.txt and Open Graph tags.

Connect the site to Google Business Profile

The website and the profile reinforce each other. A few practical rules:

  • Link the right page. For a multi-location business, each branch’s profile should link to its own /locations/<city>/ page, not the homepage.
  • Match categories and services. If the profile lists “Water heater installation”, the location page should mention it in plain text.
  • Match hours. Holiday hours change on the profile; update business.ts too so the site and schema agree.
  • Add UTM parameters to the profile’s website link (for example ?utm_source=google&utm_medium=organic&utm_campaign=gbp) so analytics separates profile clicks from other organic traffic. Your canonical tag still points at the clean URL.
  • Post real photos. The same premises photos you use on the location page help the profile too.

Google’s Business Profile help center documents verification, categories and the guidelines for representing your business. Read the guidelines before adding keywords to the business name, which they don’t allow.

Starting from a theme

If you’re building for a local client, a theme that already has service, location and contact pages saves the layout work, and you add the data files and schema above. The Home Services category is small, with 10 Komal themes for trades and repair businesses; for clinics, salons and restaurants, the Medical, Hair & Beauty and Food & Drink categories have more options. Every theme builds to static HTML, so the local SEO pieces in this guide drop straight in.

FAQ

Is Astro good for local SEO?

Yes. Astro outputs complete, server-rendered HTML with no JavaScript by default, so search engines can read every location page and phones load it quickly. Local rankings still depend mostly on your Google Business Profile, reviews and consistent NAP, which no framework controls.

Do I need a separate page for each city I serve?

Only for places where you have something specific to say: an address, a team, local projects, or services that differ. One strong page per real location beats dozens of near-identical city pages, which search engines treat as thin or doorway content.

Which schema type should a local business use?

Use the most specific subtype of LocalBusiness that fits, such as Plumber, Dentist or Restaurant, with name, address, phone, URL, geo coordinates and opening hours. Put it on the page that represents that location and generate it from the same data as the visible text.

Should I embed a Google Map on every page?

No. A map iframe is one of the heaviest things on a small business page. Put it on the contact or location page with loading="lazy", or show a “Get directions” link that opens Google Maps, and keep the rest of the site free of map scripts.

How long does local SEO take to show results?

It varies with competition and how established the business is. Fixing NAP consistency and verifying a Google Business Profile can change map visibility within weeks, while new location pages need to be crawled and earn links before they rank. Track impressions per page in Google Search Console rather than guessing.