How to show Comment Count in node template? How can I show Comment Count in a specific place of the node template?
I want to show Comment Count's of a node (article) in the submitted area instead of in the node links area. I do this already in Drupal 7 with this codes in node.tpl.php:

&lt;?php if (module_exists('comment') &amp;&amp; $node-&gt;comment) { print t('Comments'). ': ' .$node-&gt;comment_count;} ?&gt;


or this code:

&lt;a href="&lt;?php print $node_url;?&gt;#comments"&gt;&lt;?php print t('Comments'). ': '. $comment_count; ?&gt;&lt;/a&gt;


What is the equivalent code for Drupal 8?
Use this code in your theme's YOUR_THEME.theme file:

function YOUR_THEME_preprocess_node(&amp;$variables) {
  // Note: you'll probably want this only for certain content types.
  if ($variables['node']-&gt;getType() == 'YOUR_CONTENT_TYPE') {
    $variables['comment_count'] = $variables['node']-&gt;get('YOUR_COMMENT_FIELD')-&gt;comment_count;
  }
}


And then you can use it in your node.html.twig file like so:

{{ comment_count }}