Extending a base template file such as field.html.twig renders no results? So I have a custom content entity that has the typical attributes. Name, Author, Creation Date, ect. In the 'view' tab of this content entity, it displays said name, author, ect. 

When I hover over the name or title, it will display that this particular area uses field.html.twig as its default base template. I created my own custom template that extends the base template, and wanted to edit it so it would look different. 

However, doing so renders the field invisible. I tried copying the base template and pasting it into my custom twig template, however the field is still invisible. Only when I delete my custom template does it revert back to the original base template and display the field.

Here is where I am confused. My custom twig template is taking precedence, it shows that in the debug info, but I am copying the field.html.twig code into my custom code before I start editing. Why then is the fields disappearing off the page or not rendering considering that I am using the exact same coding?

Just for reference, this is a custom module template and not a themeing template I am working with. 

Here is a picture of what the field looks like when its displaying properly, otherwise it vanishs.



My hook theme code for this particular field:

  $theme['field__parent_task'] = [
    'render element' =&gt; 'content',
    'variables' =&gt; ['content' =&gt; NULL],
    'file' =&gt; 'task.page.inc',
  ];


I don't know what to put for the key names in the theme array, so I just copy and pasted from another one that was already there.
If you want to only override the field template. 

Try with with the following.


Implement hook_theme like the following no needs for variables and file keys.




  /**
     * Implements hook_theme().
     */
    function myModule_theme($existing, $type, $theme, $path) {
      return [
        'field__parent_task' => [
          'template' => 'field--parent-task',
          'base hook' => 'field',
        ],
      ];
    }




Create templates folder in your module root.  
Create field--parent-task.html.twig inside your templates folder.
Copy and the paste the base template code into your template file.
Clear the cache.