Twig conditions for node/page/view in page-title.html I am trying to set different classes in the page-title.html.twig based on what drupal is actually showing. The first condition works in a node template, but not in the page-title.html. This is a pseudo-code of what I am trying to achieve:

{%
  set classes = [
    'title--h1',
    node.type.entity.label == 'Blogpost' ? 'ico ico--time',
    page.machine_name == 'about_me' ? 'ico ico--world',
    view.machine_name == 'blogpost_list' ? 'ico ico--target'
  ]
%}
Try adding this to your MYTHEME.theme. This will provide the machine name value to your page.html.twig template files.

MYTHEME.theme:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_page($variables) {
  $variables['machine_name'] = $variables['page']['#type'];
}


Then in page.html.twig:

{%
  set classes = [
    'title--h1',
    machine_name == 'about_me' ? 'ico ico--world',
  ]
%}


{{ machine_name }}

For node.html.twig templates, use bundle to get the machine name:

{%
  set classes = [
    node.bundle == 'content__type' ? 'one-class' : 'another-class'
  ]
%}


You cannot access the bundle type in MYTHEME_preprocess_page_title() directly.