I have a simple site, the base language is English with a translation of German.
Here is the site-access setup from the ezplatform.yml
# Siteaccess configuration, with one siteaccess per default
siteaccess:
default_siteaccess: en
list:
- en
- de
groups:
site_group:
- en
- de
match:
URIElement: 1
# System settings, grouped by siteaccess and/or siteaccess group
system:
site_group:
api_keys: { google_maps: "xxx" }
cache_pool_name: '%cache_pool%'
var_dir: var/site
translation_siteaccesses: [de, en]
de:
languages: [ger-DE, eng-GB]
en:
languages: [eng-GB]
default:
content:
Works great, accessing localhost:8000 displays english content, and localhost:8000/de displays german content.
I then built a simple language switcher:
<ul>
<li>
<a href="{{ url( ez_route( null, {"language": "ger-DE"} ) ) }}" {% if ezpublish.siteaccess.name == 'de' %}class="inactive"{% endif %}>
Deutsche
</a>
</li>
<li>
<a href="{{ url( ez_route( null, {"language": "eng-GB"} ) ) }}" {% if ezpublish.siteaccess.name == 'en' %}class="inactive"{% endif %}>
English
</a>
</li>
</ul>
But now i see there is a problem with duplicate content for SEO. When on the german site-access, the language switcher prints a link to the en site access for the eng-GB language as localhost:8000/en where it should be localhost:8000.
How can i tell ez to either redirect all /en content to /? I think there must be a better solution, but i don't see how in the docs :/
When i change how the matchers work to this:
siteaccess:
default_siteaccess: en
list:
- en
- de
groups:
site_group:
- en
- de
match:
Map\URI:
/: en
de: de
For the english translation i get a // in the url for english.
We're using this matcher config and it works okay:
Note that I'm using
%site_domain%parameter which I defined myself inapp/config/parameters.yml. You can do it too, or you can use a hardcoded value.The downside is, you need to add all new siteaccesses to the list in
Compound\LogicalAndmatcher, but if you have a simple site with couple of siteaccesses, it should be fine I guess.