Seo customization
How to
First consider that in all template (all blade.php
files) you have access to some global variables, see the list and explanation here. In routes specific templates (all /src/routes/{myroute}/index.blade.php
files) you have also these variables.
Manage localised URLs
File: /config/laravel-frontend.php
'i18n' => [
'default_locale' => 'en',
'locales' => ['en'],
'enforce_localised_urls' => true,
'hide_default_locale_in_url' => false,
],
These are the defaults, you can override just one or each of them, consider that default_locale
and locales
are just used as fallbacks, if the CMS API provides them those take priority.
Add a rel="canonical"
to a specific route
File: /src/routes/myroute/index.blade.php
@push('head')
<link rel="canonical" href="{{ to('myotherroute') }}" />
@endpush
Customise the <html lang="">
File: /src/layouts/main/index.blade.php
@php
$lang = $locale === 'en' ? 'en-US' : $locale;
@endphp
<!DOCTYPE html>
<html lang="{{ $lang }}" ...
Create a common dataLayer
File: /src/layouts/main/index.blade.php
@php
$dataLayer = $user ? [[
'userLogin' => true,
'userId' => $user['id'],
'userGaId' => $user['ga_id'],
]] : [];
@endphp
...and below pass it to the component:
<x-analytics-data-layer :route-data="$data" :data="$dataLayer" />
Cookie Banner customization
File: /src/layouts/main/index.blade.php
Set an external link:
<x-cookies-banner privacy-link="https://www.example.com/{{ $locale }}/privacy-policy/" />
Set an internal route link:
<x-cookies-banner :privacy-link="to('privacypolicy')" />
privacypolicy
must be an existing route/pagename in your app.
Error pages behaviour
By default errors like 404
, 500
, etc. redirect to their specific URLS, to avoid it set RESPONSE_ERRORS_REDIRECT: false
in olmo.ts
, that will show the same pages with the right HTTP status code but under the current URL.