2

I have 2 almost identical websites. Both have almost the same layout but different colors (so different CSS file). They share most of the same templates and assets (images, css, js, videos, etc.).

Site A has two languages NL and FR. Site B has only one language FR.

Both sites have their own TLD.

How do I set this up in Craft 3? I have tried various ways, but I don't seem to be able to find the right solution.

I was thinking about creating two separate web folders, one for site A and one for site B. With subfolders for nl and fr in the webfolder for site A. That works, but than I have the problem that I cannot share my assets because they belong to different webfolders. And if I want to share a product channel for example, when I upload a product image, I want to use that same image in both sites. How will that work?

Also the baseUrl is a mystery to me. If I use @web/nl and @web/fr for site A and @web for site B, the @web gives the correct TLD as output, but the template from site B (which uses @web) are always loaded.

If I try to forgo to separate web folders, it totaly goes wrong...

Can someone please give a working example?

3

You could create 2 site groups. One group for site A and one group for site B.

Sitegroup A will contain contain 2 sites, the other one only one site. Your setup will look like this

SiteGroup A
    - Site A - language NL
    - Site A - language Fr
SiteGroup B
    - Site B - language Fr

Let's imagine your Site A - language Fr is your primary site. So it will have the base url /. Your Site A - language NL have the base url /nl.

Your Site B - language Fr will have the url whatever.you.like.fr. You don't need multiple web folders at all because Craft will route every request to web/index.php and sets the currentSite depending on the url structure.

Now you have multiple ways to setup your asset structure. You can either create multiple Asset Bundles in a plugin and load the assets you need or you can just check in your template

{% if currentSite.id == 1 %}
    load these assets
{% else %}
    load other assets
{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.