I’m working on several prototypes for building CityGrid local directories, demonstrating best practices when building web and mobile apps using CityGrid APIs. One question I’ve gotten a lot lately is how are developers supposed to build SEO friendly local directories with static pages if they aren’t allowed to cache businesses and places from the CityGrid API?
It is true, per the CityGrid Usage Requirements, you aren’t allowed to store places data in a local database or cache locally. But if you think about this, it isn’t a negative, its a positive. You don’t have to manage the potentially millions of business listings (which isn’t easy), and when a business updates their profile you don’t have to worry about having out of date information.
If you can’t store the data, then how do you build out local directories, with static pages?
To begin I would start with the root of all places search with CityGrid, the what and the where. I recommend building a folder structure that looks like this /where/what/, for example /newyorkcity/pubs/. Then in the root of this folder, put a single index page that parses the folder structure and sets your where and what variables, before making a live search using the CityGrid places API.
Now with the results of your places API search you can list the results for the user to select from. For each business listing you will get back a CityGrid places ID and public ID. The public ID is a pretty SEO friendly representation of the business, such as macs-irish-pub-new-york-city. This should work as your SEO detail, and you have two options: you can either use a mod_rewrite that will interpret this as next folder or page, or you have to statically build out a folder or page that represents each places listing. Either way your page should have a way to interpret the public ID into a numeric CityGrid ID and then make a call to the CityGrid Places API and make a detail request, returning back the full detail of a business listing.
As I write this, I realize how tough this is to explain, even though it is a pretty simple approach. The basic concept is you use your folder structure to provide the what, where and places SEO friendly detail ID. These are all the core elements you will need to make searches and detail requests against CityGrid API.
I’m working on two separate prototypes to demonstrate this, one is a mod_rewrite version and the other will statically build out pages that actually don’t store any data, except for the places ID--then make live calls again the CityGrid Places API to get what you need in real-time. Stay tuned and I will post the prototypes with accompanying blog posts, this week.