Adding a city name to a template does not make a useful local landing page. A scalable search program needs pages that reflect real service intent, contain consistent location data, connect visitors to relevant alternatives, and remain manageable as the site grows.
This is the engineering story behind Mosaic Webs' programmatic SEO implementation: six service categories across ten Indian commercial hubs, rendered from structured data through a Flask application. This walkthrough explains the system and the trade-offs behind it—not a promise that a particular architecture guarantees rankings.
At a glance: Python and Flask load city and service datasets, combine them into 60 valid service-city routes, and render shared Jinja templates on demand. Each page has localized content, a four-type JSON-LD graph, related-page navigation, and inclusion in the location sitemap.
1. The problem: manual city pages are slow and inconsistent
When a business serves multiple cities and offers multiple services, creating each landing page by hand introduces repetition and drift. Titles, service descriptions, city details, FAQs, and links can become inconsistent. Updating shared information then means editing many separate pages.
The opposite shortcut—publishing near-identical pages that only swap a place name—creates a different problem. A page should answer the visitor's local question with useful context, not simply multiply URLs. We needed a repeatable way to keep page structure consistent while making each service-and-city combination meaningful.
2. The solution: structured, data-driven page generation
We store the location and service records separately in JSON. Each city record contains its name, URL slug, state, and local business context. Each service record contains its name, slug, description, and price range. The application loads these datasets into an in-memory index and composes the valid combinations.
The resulting matrix is six service categories by ten cities: 60 addressable landing pages. Flask routes each service-city slug to its matching records; Jinja renders those records into a shared page template. The location directory uses the same data, so its city cards and service links stay aligned with the landing pages.
01. Model the data
Keep cities and services in focused datasets rather than duplicating copy in dozens of templates.
02. Build the route index
Compose valid service-city slugs at startup for direct route lookup.
03. Render on demand
Pass the matching city, service, and related options into a reusable Jinja template.
04. Connect the pages
Expose city and service alternatives through the directory and contextual internal links.
3. The tech stack: Flask, Jinja, and in-memory page caching
The integration is a Flask Blueprint, which keeps the programmatic routes modular while allowing them to register with the main application. A small data store reads the JSON files and builds lookup maps for cities, services, and their route combinations. The page renderer then supplies the selected records and related navigation data to Jinja.
cities + services (JSON)
↓
Flask startup: build slug and route indexes
↓
GET /<service>-<city>
↓
resolve records → render Jinja template → HTML response
Rendered page HTML is retained in a process-local in-memory cache, avoiding repeat template work for the same slug during that worker's lifetime. This is a simple cache rather than a bounded LRU implementation, and separate application workers do not share its contents. The architecture was designed for fast page delivery; any sub-15ms response figure should be treated as a target until measured under representative production traffic.
For a larger deployment, cache eviction, worker memory, cold starts, and shared caching should be measured and addressed based on observed traffic. Good performance work starts with profiling real requests, not treating a target as a benchmark.
4. AEO and GEO: make the page understandable, not just indexable
Answer Engine Optimization and Generative Engine Optimization are not magic markup switches. They are practical content and technical choices that make a page's subject, service area, and useful answers easier to interpret. We use clear headings, direct service descriptions, location-specific context, and question-and-answer content where it helps a visitor.
- Be explicit: identify the service and city in page titles, headings, and the body copy.
- Answer real questions: explain pricing context, likely timelines, and how the service applies to the location without promising guaranteed results.
- Keep entities consistent: use the same organization, service, and location details across visible content and structured data.
- Support discovery: link the page to its directory, sibling services, and relevant city pages.
These practices improve clarity for people and machines, but inclusion in an AI answer or search feature is never guaranteed.
5. Four-tier JSON-LD schema graph
Each programmatic landing page emits a JSON-LD @graph with four connected schema types. The data describes the page; it does not guarantee a rich result or special ranking treatment.
| Schema type | What it describes | How it connects |
|---|---|---|
| LocalBusiness | The business identity and the city context for the page. | Uses a city-specific identifier and local address/service area. |
| Service | The service offered for that location, provider, and offer context. | References Mosaic Webs as the provider and the city as the area served. |
| FAQPage | Visible questions and answers about that service and city. | Uses a page-specific identifier and matching on-page FAQ content. |
| BreadcrumbList | The visitor-facing path from Home to Services to the landing page. | Links the page into the site's navigation hierarchy. |
Structured data must match what users can see on the page and follow current search engine guidelines. We validate it as part of implementation rather than assuming that syntactically valid JSON-LD is automatically eligible for enhancements.
6. Reducing orphan pages with an internal-link mesh
Generated pages should not be isolated endpoints. The directory exposes each city and its available services; each service-city page links to related services in the same city and to the same service in other cities. That creates useful paths for visitors and crawlable relationships between the pages.
The planned network contains more than 840 strategic bidirectional internal links across the 60-page set. The useful measure is not link volume by itself: each link should help visitors reach a relevant next page and reinforce the site's navigational structure. The locations directory acts as the main hub for exploring the city-service matrix.
7. Sitemaps and search-console discovery
The location sitemap is generated from the same route index used by the application. It includes the directory and the valid service-city URLs, which reduces the chance of publishing a page in the app but forgetting it in the sitemap. The main sitemap also collects blog and core pages.
A sitemap is a discovery hint, not an indexing guarantee. After deployment, check that the sitemap returns valid XML, the canonical URLs resolve, pages are crawlable, and Search Console reports no unexpected exclusions. The URL count can change as content is added or removed, so it should be verified from the live sitemap rather than hard-coded into reporting.
8. How to replicate this responsibly
- Start with a real coverage model. Only create city and service combinations your business can support.
- Keep content specific and useful. Add meaningful local context, not just substituted city names.
- Make URL generation deterministic. Validate slugs and ensure each generated route resolves to exactly one data record.
- Connect the site deliberately. Build directory and related-page links around visitor needs.
- Validate structured data and sitemaps. Check that metadata matches visible content and URLs return the expected status.
- Measure before optimizing. Track page performance, crawl behavior, and qualified conversions; revise the system from evidence.
Related case study: explore our semantic SEO entity-mapping showcase.
Planning a multi-location search program?
Talk with Mosaic Webs about building a maintainable search architecture for your locations, services, and growth goals.
Book an Architecture Call →