A question came up on cofounderslab asking about how to deal with pages that changed content based on geolocation, in particular it was about google indexing the content.
The problem is trying to serve geo specific content on the same URL’s, this is breaking URL Semantics. The “R” in URL means Resource and in the case given the city is the resource, at least when I searched it was city specific content that I got on the site, if the city changes based on users location the resource is changing and this breaks the semantics. There are two ways to deal with this, one is sub directories and the other is sub domains.
Sub-directories:
You can redirect the user to a subdirectory ie
https://example.com/us/ca/[city here]
You can hit some gotchas with cities with the same name etc but this way the google index will see each url as unique content which it is. An example of sub directories is yelp, if I visit yelp at their main domain I get redirected from
https://www.yelp.com
to
https://www.yelp.com/sf
Sub-domains:
Craigslist uses subdomains, if I go to their main website I get redirected to https://sfbay.craigslist.org/
The thing to remember is that a web resource should remain fixed at a single URL, the method chosen has some ramifications but as you can see from Yelp and craigslist both methods work well.
I’ve used both methods and the sub domain route is a bit more work because it involves DNS and some way to manage it that isn’t manual but it’s easily doable ie attach DNS to a database etc (PowerDNS is wonderful at this).