How to show contextual links buttons in templates with minimal markup? I want to get rid of the most markup in Drupal 8 templates, but still want to have working contextual links. How to do this?
In Drupal 8 the contextual links markup is still printed via the {{ title_suffix }} variable (D7: print render($title_suffix);).

block.html.twig (default):

{%
  set classes = [
    'block',
    'block-' ~ configuration.provider|clean_class,
  ]
%}
&lt;div{{ attributes.addClass(classes) }}&gt;
  {{ title_prefix }}
  {% if label %}
    &lt;h2{{ title_attributes }}&gt;{{ label }}&lt;/h2&gt;
  {% endif %}
  {{ title_suffix }}
  {% block content %}
    {{ content }}
  {% endblock %}
&lt;/div&gt;


So a minimal version would still work:

{{ title_suffix }}
{{ content) }}


Printed result for user without the permission "Use contextual links"

&lt;div data-contextual-id="block:block=foo:|block_content:block_content=1:changed=1423224125"&gt;&lt;/div&gt;
BlaBlaBlaContent


Printed result for user with the permission "Use contextual links"

&lt;div data-contextual-id="block:block=foo:|block_content:block_content=1:changed=1423224125" class="contextual-render-processed contextual" role="form"&gt;
    &lt;button type="button" class="trigger focusable visually-hidden" aria-pressed="false"&gt;Open configuration options&lt;/button&gt;
    &lt;ul hidden="" class="contextual-links"&gt;
        &lt;li class="block-configure"&gt;&lt;a href="/admin/structure/block/manage/foo?destination=node/4"&gt;Configure block&lt;/a&gt;&lt;/li&gt;
        &lt;li class="block-contentblock-edit"&gt;&lt;a href="/block/4?destination=node/4"&gt;Edit&lt;/a&gt;&lt;/li&gt;
        &lt;li class="block-contentblock-delete"&gt;&lt;a href="/block/4/delete?destination=node/4"&gt;Delete&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
BlaBlaBlaContent


The default formatting will be destroyed because the outer class .contextual-region is missing and it's defined like this in contextual.theme.css:

.contextual-region .contextual .contextual-links {...}
.contextual-region .contextual .contextual-links li {...}
...


So you have to overwrite (https://www.drupal.org/node/1876600) this file or copy the definitions in one of your theme css files and change for example like: 

.contextual-region .contextual .contextual-links, .contextual .contextual-links {...}
.contextual-region .contextual .contextual-links li, .contextual .contextual-links li {...}


Or you place manually in the template or via JS ".contextual-region" into an outer dom element or print {{ attributes }} there. 

Printed result:

&lt;div class="block block--classic contextual-region"&gt;
    &lt;div data-contextual-id="block:block=foo:|block_content:block_content=5:changed=1423308445" class="contextual-render-processed contextual" role="form"&gt;
        &lt;button type="button" class="trigger focusable" aria-pressed="false"&gt;Open configuration options&lt;/button&gt;
        &lt;ul hidden="" class="contextual-links"&gt;
            &lt;li class="block-configure"&gt;&lt;a href="/admin/structure/block/manage/callforproposalsblock?destination=node/4"&gt;Configure block&lt;/a&gt;&lt;/li&gt;&lt;li class="block-contentblock-edit"&gt;&lt;a href="/block/5?destination=node/4"&gt;Edit&lt;/a&gt;&lt;/li&gt;
            &lt;li class="block-contentblock-delete"&gt;&lt;a href="/block/5/delete?destination=node/4"&gt;Delete&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
    BlaBlaBlaContent
&lt;/div&gt;


Remark: Without the upper .contextual-region the mouseover visibility of the contextual links icon is not working ...

Note: Current version of Drupal 8 is Beta 6 - so things may still change!