How can check if current user is node author in node template I am using Drupal 8. I would like to check if user (anonymous or logged user) is node author in node.html.twig, like below:

{# node.html.twig #}
  {% if is_author %}
    You are node author
  {% else %}
    You are not node author
  {% endif %}


Below codes not work:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHENE_preprocess_node(&amp;$variables) {
  $global $user;
  if ($variables['node']-&gt;uid == $user-&gt;uid) {
    $variables['is_author'] = TRUE;
  }
  else {
    $variables['is_author'] = FALSE;
  }
}


How could I create variable 'is_author' in node.html.twig?
/**
 * Implements hook_preprocess_HOOK() for node.html.twig.
 */
function mytheme_preprocess_node(&amp;$variables) {
   $uid = \Drupal::currentUser()-&gt;id();
   $author_id = $variables['node']-&gt;getOwner()-&gt;id();
   if ($author_id == $uid) {
     $variables['is_author'] = TRUE;
   }
   else {
     $variables['is_author'] = FALSE;
   }
}