{#-
# content array
# seo array
# shadowBaseLocale string
# localizations array
-#}
{% if localizations is not defined %}
{% deprecated 'The "urls" variable is deprecated, set "localizations" instead in the "seo.html.twig".' %}
{% set localizations = {} %}
{% for locale, url in urls %}
{% set localizations = localizations|merge({
(locale): {
locale: locale,
url: sulu_content_path(url, null, locale),
}
}) %}
{% endfor %}
{% endif %}
{#- merge seo data with _seo from attributes for custom urls -#}
{% set seo = seo|default([])|merge(app.request.attributes.get('_seo', [])|default([])) %}
{#- fallback to content title when no seo title is set -#}
{# {{ dump(content)}} #}
{% set seoTitle = seo.title|default(content.title|default()) %}
{% if seo.title is defined and (seo.title is null or seo.title is empty) %}
{% set brand_sm = 'Oakas Lane' %}
{% set brand_lg = 'Oakas Lane' %}
{# Page title of Previous directory #}
{% set PageTitleOfPreDir = '' %}
{% if content.title !='Homepage' %}
{% set page = sulu_content_load_parent(uuid, {'title': 'title'}) %}
{% if page.content.title !='Homepage' %}
{% set PageTitleOfPreDir = page.content.title%}
{% endif %}
{% endif %}
{% if seoTitle|length > 75 %}
{% if PageTitleOfPreDir != '' %}
{% set seoTitle = seoTitle~' | '~PageTitleOfPreDir~' | '~brand_sm %}
{% else %}
{% set seoTitle = seoTitle~' | '~brand_sm %}
{% endif %}
{% else %}
{% if PageTitleOfPreDir != '' %}
{% set seoTitle = seoTitle~' | '~PageTitleOfPreDir~' | '~brand_lg %}
{% else %}
{% set seoTitle = seoTitle~' | '~brand_lg %}
{% endif %}
{% endif %}
{% endif %}
{% set seoDescription = seo.description|default() %}
{% if seo.description is defined and (seo.description is null or seo.description is empty) %}
{% set discovor = 'Discover more'|trans %}
{% if content.blocks[0].PageCoverShortDescription is defined %}
{% set seoDescription = content.blocks[0].PageCoverShortDescription %}
{% endif %}
{% if seoDescription!='' %}
{% if seoDescription|length < 160 %}
{% set seoDescription = seoDescription~'. '~discovor %}
{% else %}
{% set seoDescription = seoDescription|regex("/^.*?[.!?](?:\s|$)(?!.*\)/", " ")~'. '~ discovor %}
{% endif %}
{% endif %}
{% endif %}
{% set seoKeywords = seo.keywords|default() %}
{% set seoRobots = '' %}
{%- if seo.noIndex|default(false) -%}
{% set seoRobots = seoRobots ~ 'noIndex' -%}
{%- else -%}
{% set seoRobots = seoRobots ~ 'index' -%}
{%- endif -%}
{%- if seo.noFollow|default(false) -%}
{% set seoRobots = seoRobots ~ ',noFollow' -%}
{%- else -%}
{% set seoRobots = seoRobots ~ ',follow' -%}
{%- endif -%}
{% set seoCanonical = seo.canonicalUrl|default() %}
{%- if not seoCanonical and shadowBaseLocale and localizations[shadowBaseLocale]|default() %}
{% set seoCanonical = localizations[shadowBaseLocale].url %}
{%- endif -%}
{#- render blocks -#}
{%- if app.request.get('_route') == "sulu_search.website_search" -%}
{% if app.request.locale == 'en'%}
{% set seoTitle = 'Search Page | Oakas Lane' %}
{# {% else %}
{% set seoTitle = 'Oakas Lane Search Page' %} #}
{% endif %}
{% if app.request.locale == 'de' %}
{% set seoTitle = 'Suchseite | Oakas Lane' %}
{% endif %}
{% if app.request.locale == 'fr' %}
{% set seoTitle = 'Page de recherche | Oakas Lane' %}
{% endif %}
{%- endif -%}
{%- block title -%}
{%- if seoTitle -%}
<title>{{ seoTitle }}</title>
{%- endif -%}
{%- endblock -%}
{%- block description -%}
{%- if seoDescription -%}
<meta name="description" content="{{ seoDescription }}"/>
{%- endif -%}
{%- endblock -%}
{%- block keywords -%}
{%- if seoKeywords -%}
<meta name="keywords" content="{{ seoKeywords }}"/>
{%- endif -%}
{%- endblock -%}
{%- block robots -%}
{%- if seoRobots -%}
{% if app.request.get('_route') != "sulu_search.website_search" %}
<meta name="robots" content="{{ seoRobots }}"/>
{% else %}
<meta name="robots" content="noindex,follow" />
{% endif %}
{%- endif -%}
{%- endblock -%}
{%- block urls -%}
{#- when only one language do not show alternative -#}
{%- if localizations|length > 1 -%}
{%- for localization in localizations -%}
{%- if localization.alternate is not defined or localization.alternate -%}
{% if localization.locale !='fr' %}
{% if app.request.get('_route') == "sulu_search.website_search" %}
{# <link rel="alternate" href="{{ app.request.getSchemeAndHttpHost() }}{{ path('sulu_search.website_search' ,{'lang':localization.locale }) }}" hreflang="{{ localization.locale|replace({'_': '-'}) }}"/> #}
<link rel="alternate" href="{{ app.request.getSchemeAndHttpHost() }}{{ path('sulu_search.website_search' ,{'lang':localization.locale }) }}" hreflang="x-default"/>
{% else %}
{# {% if request.defaultLocale == request.resourceLocatorPrefix|replace({'/': ''}) %}
<link rel="alternate" href="{{ request.portalUrl }}" hreflang="x-default"/>
{% else %} #}
<link rel="alternate" href="{{ request.portalUrl }}" hreflang="{{ request.resourceLocatorPrefix|replace({'/': ''}) }}"/>
{# {% endif %} #}
{% endif %}
{% endif %}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endblock -%}
{%- block canonical -%}
{#- Set canonical to itself if a bot clone the page -#}
{% if app.request.get('_route') == "sulu_search.website_search"%}
<link rel="canonical" href="{{ app.request.getSchemeAndHttpHost() }}{{ path('sulu_search.website_search' ,{'lang':app.request.locale }) }}"/>
{% else %}
<link rel="canonical" href="{{ seoCanonical|default(app.request.uri) }}"/>
{% endif %}
{%- endblock -%}