Add Button to Node View I want to add custom button on node page. 



I tried with hook_node_view but it didn't show up.

like this: 

function mymodule_node_view(array &amp;$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

$build['mybutton'] = [
  '#type'       =&gt; 'button',
  '#name'       =&gt; 'mybutton_name',
  '#value'      =&gt; t('Click Here'),
  '#attributes' =&gt; [ 'class' =&gt; 'button button--primary'],
  '#weight'     =&gt; -11,
];


}

What am I doing wrong?

EDIT:

Here is the template

{#
/**
 * @file
 * Display Suite 2 column stacked template.
 *
 * Available variables:
 * - outer_wrapper: outer wrapper element
 * - header_wrapper: wrapper element around header region
 * - left_wrapper: wrapper element around left region
 * - right_wrapper: wrapper element around right region
 * - footer_wrapper: wrapper element around footer region
 * - attributes: layout attributes
 * - header_attributes: attributes for header region
 * - left_attributes: attributes for left region
 * - right_attributes: attributes for right region
 * - footer_attributes: attributes for footer region
 * - header: content of header region
 * - left: content of left region
 * - right: content of right region
 * - footer: content of footer region
 */
#}

&lt;{{ outer_wrapper }}{{ attributes.addClass('ds-2col-stacked', 'clearfix') }}&gt;

  {{ title_suffix.contextual_links }}

  &lt;{{ header_wrapper }}{{ header_attributes.addClass('group-header') }}&gt;
    {{ header }}
  &lt;/{{ header_wrapper }}&gt;

  &lt;{{ left_wrapper }}{{ left_attributes.addClass('group-left') }}&gt;
    {{ left }}
  &lt;/{{ left_wrapper }}&gt;

  &lt;{{ right_wrapper }}{{ right_attributes.addClass('group-right') }}&gt;
    {{ right }}
  &lt;/{{ right_wrapper }}&gt;

  &lt;{{ footer_wrapper }}{{ footer_attributes.addClass('group-footer') }}&gt;
    {{ footer }}
  &lt;/{{ footer_wrapper }}&gt;

&lt;/{{ outer_wrapper }}&gt;
Just tried it out myself and for me it didn't work using your malformatted #attributes array. After I fixed it the following did work. class must provide another array.

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function MYMODULE_node_view(array &amp;$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  $build['mybutton'] = [
    '#type'       =&gt; 'button',
    '#name'       =&gt; 'mybutton_name',
    '#value'      =&gt; t('Click Here'),
    '#attributes' =&gt; ['class' =&gt; ['button', 'button--primary']],
    '#weight'     =&gt; -11,
  ];
}