Best Practice for multiple domains sharing 80% same content

If got two domains that share the same sitepackage. They also share allmost all of the content. Except some stuff in the footer like Contact details.

So I added a property addressDomain1 and addressDomain2 to my Vendor.SitePackage:HomePage where I can edit the data. This is derived by Vendor.SitePackage:Page and shown on all pages, without editing feature. But in this case I only show addressDomain1 on domain1 and addressDomain2 on domain2.

In my fusion of for the Vendor.SitePackage:Homepage I’ve got the following code:

contact = Neos.Fusion:Join {
    domain1Contact = Neos.Fusion:Tag {
        tagName = 'div'
        content = Neos.Fusion:Join {
            title1 = Neos.Fusion:Tag {
                tagName = 'h3'
                content = 'Kontakt domain1.com'
            }
            domain1 = Neos.Neos:Editable {
                property = 'domain1Contact'
                block = false
            }
            title2 = Neos.Fusion:Tag {
                tagName = 'h3'
                content = 'Kontakt domain2.com'
            }
            domain2 = Neos.Neos:Editable {
                property = 'domain2Contact'
                block = false
            }
        }
        @process.contentElementWrapping = Neos.Neos:ContentElementWrapping
    }
}
domain1Contact = Neos.Fusion:Tag {
    tagName = 'div'
    content = ${q(site).property('domain1Contact')}
    @if.isdomain1 = ${String.endsWith(Configuration.setting('Neos.Flow.core.context'), 'domain1') == true}
}
domain2Contact = Neos.Fusion:Tag {
    tagName = 'div'
    content = ${q(site).property('domain2Contact')}
    @if.isdomain2 = ${String.endsWith(Configuration.setting('Neos.Flow.core.context'), 'domain2') == true}
}

Then in my fluid template I’ve got this little code:

            <f:if condition="{neos:rendering.inBackend()}">
                <f:then>
                    {contact -> f:format.raw()}
                </f:then>
                <f:else>
                    {domain1Contact -> f:format.raw()}
                    {domain2Contact -> f:format.raw()}
                </f:else>
            </f:if>

This works fine so far. BUT:

When the editors make a change, they start the system on domain1/neos make the change and publish it to live. The changes on domain1 are accepted as they are made. But for domain2 I have to clear the cache from command line with FLOW_CONTEXT=Development/domain2. Since the editors don’t have a command line to do this, I’ve got a problem.

So the question is:

  1. Is there a possitibility to configure the system to delete the cache for a different context?
  2. Which other possibility would there be to handle this situation?

Hi,

This approach might not be so good.

If you have different content trees for each domain you should manage the contact data in each sites homepage and use the sites data for rendering. Then you don‘t have caching issues

You shouldn‘t read and use the FLOW_CONTEXT but instead define a configuration setting based on the context and access that if you must.

If you still want to do it this way you have to change the caching behavior of your footer to not only include the site as cache tag but the site in which you make the changes.

But I would recommend to manage each site on its own in the backend. But I also didn‘t fully understand how your content is shared and built up.

Hi Sebastian,

thx for your reply.

The content trees are besides the footer and contact page identical. And content will be enormous. Otherwise of course there would be two sites configured.

The idea of making different configuration settings is definitely a good idea!

I did a little change to make it simpler:

domain1Contact = Neos.Fusion:Tag {
    tagName = 'div'
    content = Neos.Neos:Editable {
        property = 'domain1Contact'
        block = false
    }
    @if.isDomain1 = ${String.endsWith(Configuration.setting('Neos.Flow.core.context'), 'domain1') == true}
    @process.contentElementWrapping = Neos.Neos:ContentElementWrapping
}
domain2Contact = Neos.Fusion:Tag {
    tagName = 'div'
    content = Neos.Neos:Editable {
        property = 'domain2Contact'
        block = false
    }
    @if.isDomain2 = ${String.endsWith(Configuration.setting('Neos.Flow.core.context'), 'domain2') == true}
    @process.contentElementWrapping = Neos.Neos:ContentElementWrapping
}

and changed the fluid code to:

<div>
    {domain1Contact -> f:format.raw()}
    {domain2Contact -> f:format.raw()}
</div>

So when I want to change the contact details for domain2 I will have to enter neos over domain2/neos and for contact1 I will have to enter neos over domain1/neos.

This way caching works correct.

To follow the idea of managing each site on its own:

Is there a possibility to share parts of tree contents between the sites? Something like mounting points as they exist in the “elder brother”?

No that’s currently not easily doable. Or I don’t know of a solution to that yet, because nodes are absolutely positioned in the node structure and cannot be attached to multiple places.

In most cases you don’t want to reuse so much content anyway because of duplicate content problems with SEO.

But there are other concepts of course like editable “template pages” than can then be used in other places. Not sure if there are already plugins that offer that out of the box.

I always found that in those complex situations are simpler different solution is often available and is better to manage for editors and integrators at the end.

SEO ist of course a point. I don’t know how they want to solve that.

But I don’t understand your last sentence. What do you mean?

Yes for example discussing first how to solve the duplicate content issue. Then maybe the whole concepts already collapses.

Or think about what they plan in the future with it and how it will evolve. Maybe there is a different solution that will work out better.
Or a simple solution that will initially be a bit more work but is easier to solve and adapt to their needs later on.

Just another idea: if both sites have almost the same content, maybe think of building them as dimension.
You could have a dimension “site” with 2 values “Site A” and “Site B”, where you configure a fallback to “Site A”.
This ways the content is mainly managed in the dimension “Site A”.

There are already good solutions to resolve the matching dimension by request domain, e.g. flowpack/neos-dimensionresolver

1 Like

I will give dimensions a try. That would be a solution.