Dev.to WebDev 🛠 Dev 👁 2 📖 4 min read

Structured Data for Static Directory Pages: What to Mark Up and Skip

Structured data is one of those tasks that directory developers either ignore entirely or overdo. On a static directory site built from a Google Maps export, it is easy to generate JSON-LD for every listing on every page

Structured data is one of those tasks that directory developers either ignore entirely or overdo. On a static directory site built from a Google Maps export, it is easy to generate JSON-LD for every listing on every page, with ratings, hours and coordinates included. Some of that helps search engines and other tools understand your pages. Some of it conflicts with Google's guidelines.

This post walks through what is reasonable to mark up on the common directory page types and what to leave out. It is written for developers who build directory sites for themselves or for clients. More technical notes on AI search and directories are in these tech notes for directory builders.

Start from what the page actually shows

Google's general structured data guidelines say markup should describe content that is visible on the page. That rule settles most questions. If a city page lists twenty businesses with names and links, you can describe that list. If a field exists in your export but does not appear on the page, it should stay out of the markup too.

Static generators make it tempting to dump every column into JSON-LD because the data is already there. Resist that. Generate markup from the same template variables that render the visible page, so the two cannot drift apart.

City and category pages

City and category pages are lists. Schema.org's ItemList type fits them: each item points to a listing page URL with its position in the list. A minimal example:

{
  "@context": "https://schema.org",
  "@type": "ItemList",
  "name": "Plumbers in Springfield",
  "itemListElement": [
    {"@type": "ListItem", "position": 1, "url": "https://example.com/springfield/plumbers/acme-plumbing/"},
    {"@type": "ListItem", "position": 2, "url": "https://example.com/springfield/plumbers/river-city-drains/"}
  ]
}

Keep it simple. The list markup tells crawlers how the page is organized and which detail pages belong to it. Pair it with BreadcrumbList markup that matches your visible breadcrumb trail, such as Home, county, city and category.

Listing pages

A single listing page describes one business, so LocalBusiness, or a more specific subtype such as Plumber or Dentist, is the natural type. Include the fields that appear on the page: name, address, phone, the business website, opening hours if you show them and coordinates if the page has a map.

Two things need care. First, use the business website as the url or sameAs value only when you are confident it is correct, because a wrong link in markup is still a wrong link. Second, remember that your directory is a third party describing the business. The markup is your description, built from public listing data, so keep it as factual and plain as the visible page.

Hours deserve a note of their own. Exports capture hours at one moment, and businesses change them for holidays and seasons. If you output openingHoursSpecification, regenerate it with every data refresh, and consider leaving it out for listings whose hours you have not refreshed in months. Stale hours in markup are just as misleading as stale hours on the page.

Ratings are the main thing to skip

Most Google Maps exports include a star rating and review count, and many directories display them. Adding an AggregateRating to the listing markup feels natural. Do not do it.

Google's review snippet guidelines tell sites not to aggregate reviews or ratings from other websites and say ratings should come directly from users. A Google rating copied from an export fails both tests. You can still show the rating on the page with clear attribution, such as "4.6 on Google from 120 reviews," but leave it out of the structured data. If your site collects its own reviews from real users, that is a different situation with its own rules, so read them first.

Testing the output

Run a sample of each page type through Google's Rich Results Test and the Schema Markup Validator. The first shows what Google can read, and the second checks the markup against the schema.org vocabulary. Fix errors in the template, not on individual pages.

Then spot-check after every build. A common failure in static directories is a listing with a missing field, such as no phone number, that produces malformed JSON when the template assumes the field exists. Add a build step that parses every JSON-LD block and fails the build on invalid output. It takes a few lines in most build scripts and catches problems before they ship.

Markup is only part of what crawlers read. For the HTML side, this note on how AI assistants read local directory pages covers what tends to matter.

Questions about structured data on directories

Will ItemList markup give my city pages rich results?

Probably not by itself. Google shows list-style rich results only for certain content types. The markup still describes the page structure clearly, which is the main reason to add it.

Should every listing on a city page get full LocalBusiness markup?

No. Put full LocalBusiness markup on each listing's own page and keep city pages to an ItemList of URLs. Repeating full business markup for every item on a long list adds weight without much benefit.

Do AI assistants use structured data?

Some systems may read it, but the companies behind them rarely say exactly how. Clear, server-rendered HTML with the same facts remains the safer bet. 1 Click Directory Builder turns a Google Maps export into a complete directory site, which gives you consistent page types to build templates and markup around.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.