prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
346 stars 100 forks source link

Multi domain #343

Open j2vos opened 3 weeks ago

j2vos commented 3 weeks ago

Hello,

I have a site with 2 domains:

www.domain.fr www.domain.be

The .be domain manages 2 languages: www.domain.be/be-fr www.domain.be/nl-be

This is the same content on both sites (Change of translation)

How to configure the presta_sitemap.yaml so that it correctly generates the 2 sitemaps?

THANKS Jeremy

yann-eugone commented 3 weeks ago

Hi Jeremy,

I've never done such things myself, the double requirement of domain + prefix can be a bit tricky here

I believe you will have to start with configuration of alternates in the bundle: https://github.com/prestaconcept/PrestaSitemapBundle/blob/4.x/doc/2-configuration.md#translated-routes

presta_sitemap:
    alternate:
        enabled: true
        default_locale: 'fr_FR'
        locales: ['fr_FR', 'be_FR', 'nl_BE']
        i18n: symfony

But then, it will be Symfony's responsibility to determine what domain should be used for what language https://symfony.com/doc/current/routing.html#localized-routes-i18n

controllers:
    resource: '../../src/Controller/'
    type: attribute
    prefix:
        fr_FR: '' # don't prefix URLs for the default locale
        be_FR: '/be-fr'
        nl_BE: '/nl-be'
    host:
        fr_FR: 'www.domain.fr'
        be_FR: 'www.example.be'
        nl_BE: 'www.example.be'

Given that you are using Symfony for your translated routes Otherwise you will have to add routes all by yourself