How to hide all tabs (local tasks) except the user account tabs? I want to hide all tabs (local tasks) for non-admin users except the tabs on the user account page (for example, I want to hide tabs on nodes of all content types).

To hide the tabs, I added a check for admin permission in my theme template: templates/menu/menu-local-tasks.html.twig

{% if user.hasPermission('administer nodes') %}
  {% if primary %}
    &lt;h2 class="visually-hidden"&gt;{{ 'Primary tabs'|t }}&lt;/h2&gt;
    &lt;ul class="tabs--primary nav nav-tabs"&gt;{{ primary }}&lt;/ul&gt;
  {% endif %}
  {% if secondary %}
    &lt;h2 class="visually-hidden"&gt;{{ 'Secondary tabs'|t }}&lt;/h2&gt;
    &lt;ul class="tabs--secondary pagination pagination-sm"&gt;{{ secondary }}&lt;/ul&gt;
  {% endif %}
{% endif %}


This works, but it hides the tabs on the user account page as well.

I tried to find a more specific template of menu-local-tasks for the user account. I turned on twig debugging, but these were the suggestions:

&lt;!-- FILE NAME SUGGESTIONS:
   * block--mytheme-local-tasks.html.twig
   x block--local-tasks-block.html.twig
   * block--core.html.twig
   * block.html.twig
--&gt;


All of these affect the entire site; there is no way to target just the user account local tasks.

Is there a way to do this with theme templates?  I chose this approach rather than trying to unset the local tasks in a hook because in a template you can do it in just a line or two of code.
I wouldn't recommend not doing this by code, this can be achieved using built-in configuration settings, by using a second block with proper rules. Try this:


Go to Structure &gt; Block layout 
Select your theme
Place a second tabs block where-ever you want it
Limit the visibility on the block fitting your requirements


Most likely limit Pages to something like user/*
and by Roles, e.g. Authenticated user
(remember that administrators are authenticated users too, so you might need more specific roles to to prevent admins seeing tabs block twice; or add the "hide"-option on user-pages for the first, original tabs block )