Is Contexts the right way to do this?

I’ve got a website and the client is rapidly moving into the North American market so wants to also incorporate a .com for that market (the .com does use a different domain name). 95% of the site will be exactly the same as the - things that will be different are…
Social media links (all contained in one chunk)
Address info (currently contained in one chunk)
Email address (again, uses a chunk throughout the site)
Phone number (again, uses a chunk throughout the site)
Contact page / form
…so essentially all the pages are the same apart from some info in the header and footer. I’ve never used a separate context and if this is the right way to go, any tips on what not to do under these circumstances?

I am a fan of using contexts for multiple sites… but if it really only is stuff in templates that’s different, I built an extra years ago that lets you set different settings per domain:

You’d need to convert those details into settings first, but then that could help.

Might want to consider the SEO impact of having duplicates sites too, perhaps setting up hreflang meta tags to indicate to google what’s what.


I agree with Mark about SEO impact.

A fairly simple way of achieving this is to have a plugin OnHandleRequest that adds a variable like CA or US based on the domain. Then you can call your chunks like [[$emailChunk[[!+location]]]].

The great thing about MODX is there are infinite ways to achieve this.

My only real concern would be the overhead of not caching those, so they can switch on the fly. You could maybe put getCache in-front of it, and use the [[!location]] as your cacheKey.

1 Like

Thank you Mark. I agree with the possible SEO impact and we could potentially just switch to using .com rather than - that would work for both US and UK visitors but then we’d potentially lose all the clout we’ve built up on the site and I’d still have to find a way to show different addresses and contact details for both sets of visitors. Luckily nearly all my meta tags even down to lat,long are controlled by a set of chunks that I categorise as ‘customisables’. The sites do share a common product catalogue so there’s no getting away from that duplicate information anyway. I’ve had a quick look at the documentation on GitHub and can’t help thinking I’m going to run into trouble. For instance, how does this affect https info contained in the htaccess file? I can understand how I can set element properties for something like site_name but but what about chunks?

1 Like

Thank you Mat - that does sound tempting. Unfortunately I’m not knowledgeable enough for that level of work i.e creating a plugin like that. And I’m probably not clever enough to work out the possible implications of doing it that way!

to answer your questions, https shouldn’t be affected on any of the contexts

for chunks, again they are there to provide flexibility. You could have uk chunks and us chunks for certain bits of your site, and have others unified for another part of your site. that way, all your online content can be organized and then updated across sites/templates.

So, for online contact info, you might have it on both sites. If you were a media company with changing masthead and contact addresses, you would have a uk and US/worldwide/wherever chunks.

You could even have an app on the site that dynamically found say discounted items, and use location information, regardless of context. I might be browsing your uk site for a specific reason and still get served ads about a local sale.