How to remove empty div created by routing.yml file by specified routes? I have 2 routes

games.one:
  path: '/math/one'
  defaults:
    _controller: '\Drupal\games\Controller\GamesController::one'
    _title: 'My Title'
  requirements:
    _permission: 'access content'


games.two:
  path: '/math/two'
  defaults:
    _controller: '\Drupal\games\Controller\GamesController::two'
  requirements:
    _permission: 'access content'


Route games.one has _title and Route games.two does not have. Now the issue is When I access route game.two, It shows an empty div for title.

How to remove this empty div?
You can do this by overriding the page.html.twig for that page and stripping out the title.

To override the template for that specific page you should probably alter the hook suggestions:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function THEME_NAME_theme_suggestions_page_alter(array &amp;$suggestions, array $variables) {

  if ($node = \Drupal::routeMatch()-&gt;getRouteName() == 'games.two') {
    $suggestions[] = 'page__no_title';
  }
}


Now you can copy the page.html.twig template to  your theme folder, rename it to page--no-title.html.twig and strip out the title tag.

Hope this helps