Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

albertovalerio's avatar

Laravel Multilingual Routing and SEO

If I build a multilanguage routing system like this below and a language switcher where I change the value of the locale variable with a post request, will I have all the views (i.e. mysite.com/en; mysite.com/it; mysite.com/es;) indexed on Google SERP, or only the ones in the default language set as "locale" in config/app.php?

Route::group(['prefix'=>'/{locale}/'],function(){
    Route::get(__('strings.home'), 'PublicController@index')->name('homepage');
    Route::get(__('strings.about'), 'PublicController@about')->name('about');
    Route::get(__('strings.services'), 'PublicController@services')->name('services');
    Route::get(__('strings.products'), 'PublicController@products')->name('products');
...etc...
});
0 likes
2 replies
click's avatar
click
Best Answer
Level 35

..or only the ones in the default language set as "locale" in config/app.php?

No all of them as long as the googlebot can find and crawl the URL's. If you have a language switcher with actual links google will find them and crawl them.

You can also help google a bit by creating a sitemap that includes the language key or add meta tags to you head and supply alternate pages see: https://support.google.com/webmasters/answer/189077

More about: "Managing multi-regional and multilingual sites" https://support.google.com/webmasters/answer/182192?hl=en

1 like
aurawindsurfing's avatar

Hi @albertovalerio

I use arcanedev/localization for my localized routing

Apart from the routes you also need to provide metadata for all you locales like so:

<meta property="og:locale"content="{{ app()->getLocale() }}" />
@foreach(localization()->getSupportedLocales() as $key => $locale)
    <meta property="og:locale:alternate"content="{{ $key }}" />
@endforeach

then also in your sitemap (I use spatie/laravel-sitemap)

->add(Url::create(url('/en'))
            ->setPriority(1.0)
            ->setLastModificationDate(Carbon::yesterday())
            ->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
            ->addAlternate(url('/fr'), 'fr'))
            ->addAlternate(url('/de'), 'de'))
            ->addAlternate(url('/pl'), 'pl'))

Hope it helps!

1 like

Please or to participate in this conversation.