How to specify a twig template for a custom Drupal 8 page?
I got that to work. Here's my solution.

Create a template in path/to/your/module/templates/my-custom-page.html.twig.

/**
 * Implements hook_theme().
 */
function mymodule_theme($existing, $type, $theme, $path)
{
    return [
        'my_custom_page' =&gt; [
            'render element' =&gt; 'custom_page',
            'path' =&gt; $path . '/templates',
            'template' =&gt; 'my-custom-page',
            'variables' =&gt; [
                'var1' =&gt; 'default value for var1',
            ],
        ],
    ];
}


I couldn't figure out what render element is for, but it is required.

variables element defines the variables available in your template and provides default values for them. You can override them in your controller.

use Drupal\Core\Controller\ControllerBase;

/**
 * Class CustomPageController
 */
class CustomPageController extends ControllerBase
{

    public function getPage()
    {
        return array(
            '#theme' =&gt; 'my_custom_page',
            '#var1' =&gt; 'Actual value for var1',
        );
    }

}


Clear the cache and visit your custom page route. Everything should work.

Helpful links:


Render API
overview
hook_theme()