URL structure is one of the few decisions in a static directory that is expensive to change later. Once city and listing pages are indexed and linked from other sites, renaming them means redirects, lost links and a messy few weeks in Search Console. It's worth an hour of thought before the first build.

This post is for developers building static local directory sites from Google Maps data. It covers how to structure paths, how to generate slugs that survive messy business names, and the edge cases that show up once real data hits the generator: duplicate city names, duplicate business names and listings that disappear between exports.

Pick a hierarchy and keep it shallow

A local directory has a few natural levels: region or county, city, category and listing. You don't need all of them in every URL. A common and readable pattern is:

  • /county-name/ for county pages
  • /county-name/city-name/ for city pages
  • /county-name/city-name/category/ for category pages within a city
  • /listing/business-name-city/ for listing pages

Putting listings under a flat prefix rather than deep inside the city and category tree has a practical benefit. A business that belongs to two categories has one canonical URL instead of two copies. It also means a recategorized business keeps its URL.

Whatever you choose, make the path mirror the navigation. If the breadcrumb on a page reads County, City, Category, the URL should follow the same order. Search engines and people both read URLs, and a path that matches the page is easier to trust.

Generate slugs that survive real data

Business names from Google Maps include accented characters, ampersands, emoji, apostrophes and the occasional name that's entirely in capitals. Your slug function has to turn all of that into something stable and readable.

A small Python version that handles most cases:

import re, unicodedata def slugify(text, max_len=60): text = unicodedata.normalize("NFKD", text) text = text.encode("ascii", "ignore").decode("ascii") text = text.lower().replace("&", " and ") text = re.sub(r"[^a-z0-9]+", "-", text).strip("-") return text[:max_len].rstrip("-") or "listing" 

The normalize step turns "Café" into "Cafe" rather than dropping the letter. The ampersand replacement keeps "Smith & Sons" readable as smith-and-sons. The length cap matters because keyword-stuffed Google Maps names can run to a hundred characters or more. The fallback catches names made entirely of characters that don't survive the conversion.

Handle duplicate city names

Every country has towns that share a name. In a single-state directory you'll still meet places like two Springfields in different counties, or a city and a township with the same name. If city slugs are generated from the city name alone, one page will overwrite the other at build time, often silently.

Nesting cities under counties solves most of this, which is one reason to include the county level. If your directory covers several states, add the state as well. Either way, add a check to the build: collect every output path in a set and fail loudly when a path is generated twice. A build that stops with a clear error is far better than a site where one town's listings quietly vanish.

Handle duplicate business names

Chains and franchises create the same problem at the listing level. Five locations of the same pizza chain produce five identical slugs. Appending the city usually fixes it. When two locations sit in the same city, append the street name or a short piece of the Google place ID.

Use the place ID as the stable key in your data, and treat the slug as a display layer derived from it. Store the mapping between place ID and slug from one build to the next. If a business changes its name slightly, you can then choose to keep the old slug, which keeps the URL stable and avoids breaking links.

Decide what happens when a listing disappears

Between exports, some businesses close and some are removed at their request. Their pages will disappear from the next build. Decide how your host handles that. A plain 404 is acceptable for a business that no longer exists. A redirect to the city's category page is friendlier when the listing had incoming links, as long as the target page is genuinely related.

Keep the slug history file mentioned above, and generate redirects from it automatically during the build. Many static hosts accept a redirects file in a simple format, and generating it from data avoids maintaining it by hand.

Keep URLs consistent everywhere

Pick one form for trailing slashes and use it in internal links, canonical tags and the sitemap. Mixed forms create duplicate URLs that point to the same page. Lowercase everything. Avoid query strings for anything you want indexed, such as filtered views, and keep those as client-side state.

City pages are usually the URLs that get the most search traffic, so they deserve the most care. The guide on writing city pages for a local directory covers the content side once the paths are settled. For more on the technical side of static directories, see the static directory code blog.

If you would rather skip building the generator, 1 Click Directory Builder turns a Google Maps export from Outscraper, Apify or any scraper into a complete static directory site with county and city pages, search, filters, a map and a sitemap.

Questions about directory URL design

Should listing URLs include the category?

Usually not. Businesses change or gain categories, and a category in the URL either duplicates pages or forces redirects.

Is it worth putting the place ID in every URL?

Only as a tiebreaker. Readable slugs are friendlier to share, and the place ID can stay in your data.

How long should a slug be?

Short enough to read at a glance. Capping around sixty characters keeps most names intact while trimming keyword-stuffed ones.