Custom content entity template preprocess doesn't contain any variables I've created a custom entity and a template for it.

path to template /modules/custom/my_module/templates.

My theme_hook()

/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path) {
  return [
    'my_module' =&gt; [
      'path' =&gt; $path . '/templates',
      'template' =&gt; 'my-module',
      'variables' =&gt; [
        '#my_entity' =&gt; '',
      ],
    ],
  ];
}


My preprocess

/**
 * Prepares variables for My Module templates.
 *
 * Default template: my-module.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - elements: An associative array containing the user information and any
 *   - attributes: HTML attributes for the containing element.
 */
function template_preprocess_my_template(array &amp;$variables) {
  // Fetch my_entity Entity Object.
  $my_entity = $variables['elements']['#my_entity'];

  // Helpful $content variable for templates.
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}


But all I get is the user object nothing else.

Did I miss something?
I needed to remove the #

/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path) {
  return [
    'my_module' =&gt; [
      'path' =&gt; $path . '/templates',
      'template' =&gt; 'my-module',
      'variables' =&gt; [
        'my_entity' =&gt; '',
      ],
    ],
  ];
}


now i have my entity and can work on :)