I am new to Drupal 8 theming and I've been long time trying the following:
I want to add classes to page-title in the template, page-title.html.twig
. Two new classes:
1.- 'page_title'
2.- The real title of the page
The code I'm using is,:
{{ title_prefix }}
{%
set classes = [
'page-title',
title|clean_class
]
%}
{% if title %}
<h1{{ title_attributes.addClass( classes ) }}>{{ title }}</h1>
{% endif %}
{{ title_suffix }}
it renders:
<h1 class="js-quickedit-page-title page-title array">FORMACIÓN: CURSOS Y TALLERES</h1>
The string 'page-title' is working well but the variable title provoke an error:
Notice: Array to string conversion in Drupal\Component\Utility\Html::getClass() (line 72 of core\lib\Drupal\Component\Utility\Html.php).
And print the class, array.
Any help?