DEV Community

Amanda Jayathilaka
Amanda Jayathilaka

Posted on

How to Add LocalBusiness JSON-LD Schema to a Directory Website

Add structured data to your directory pages so search engines understand each location's name, address, and phone number.

If you run a directory site, structured data helps search engines understand what each page is about. Done right, it can make your listings eligible for richer search results.

I applied this to a Chase Bank branches directory, where every page represents one physical location.

Pick the right type

Schema.org has BankOrCreditUnion, which fits a bank branch. For other businesses use LocalBusiness or a more specific subtype.

Example JSON-LD

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BankOrCreditUnion",
  "name": "Chase Bank, Dallas",
  "telephone": "+1-972-690-8600",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "LBJ Freeway and Abrams Road",
    "addressLocality": "Dallas",
    "addressRegion": "TX",
    "addressCountry": "US"
  },
  "geo": {
    "@type": "GeoCoordinates",
    "latitude": 32.9,
    "longitude": -96.77
  }
}
</script>
Enter fullscreen mode Exit fullscreen mode

The values above are examples. Use your own verified data.

Generate it from your data

Do not hand-write this for every page.

function buildSchema(branch) {
  return {
    "@context": "https://schema.org",
    "@type": "BankOrCreditUnion",
    name: branch.name,
    telephone: branch.phone,
    address: {
      "@type": "PostalAddress",
      streetAddress: branch.street,
      addressLocality: branch.city,
      addressRegion: branch.state,
      addressCountry: "US",
    },
  };
}

const tag = `<script type="application/ld+json">${JSON.stringify(buildSchema(branch))}</script>`;
Enter fullscreen mode Exit fullscreen mode

Validate it

Test every template with Google's Rich Results Test and the Schema Markup Validator before you publish thousands of pages.

Common mistakes

  • Marking up data that is not visible on the page.
  • Using an incomplete phone number. Use the international format.
  • Duplicating the same schema block across different pages.
  • Forgetting to escape quotes in names and addresses.

Structured data will not magically rank a page, but it removes ambiguity, and that is worth the 20 minutes.

Top comments (0)