How do I define a route and controller for the home page? A custom module called TSA contains almost all of the functionality for the /tsa subsite on my Drupal 8 multisite. 

I want to define a route for http://localhost/tsa/, so that I can serve up dynamic content on the homepage depending on who the authenticated user is.

Here's tsa.routing.yml:

tsa.homepage:
  path: '/'
  defaults:
    _title: 'TSA Home'
    _controller: '\Drupal\tsa\Controller\HomepageController::content'
  requirements:
    _permission: 'access content'


And here's src/Controller/HomepageController.php:

&lt;?php

namespace Drupal\tsa\Controller;
use Drupal\Core\Controller\ControllerBase;

class HomepageController extends ControllerBase {
  public function content() {
    return [
      '#type' =&gt; 'markup',
      '#markup' =&gt; 'Hello World from the HomepageController',
    ];
  }
}


But when I navigate to http://localhost/tsa, I just get Page Not Found.

Why doesn't it work? How should I go about doing this?
This is a classic case of trying to do something in the non-Drupal way -- conceptually, defining a custom route for your home page route makes sense, and it's possible in other frameworks, but Drupal has a different way of doing things that makes this approach completely unintuitive.

Here's how to do it:


Define your route as something other than '/' (i.e. '/students/overview')
In /admin/config/system/site-information, set your "Default Front Page" to whatever your route was:




Voila!