How can I reference an entity field in a template file? I am trying to theme the node add/edit form for a custom content type (for example, Album). I implemented hook_form_alter() in the theme.
function mytheme_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  switch ($form_id) {
    case &quot;node_album_form&quot;:
      $form['#theme'] = ['node_album_edit_form'];
      break;
  }
}

That correctly intercepts the node add/edit form and passes it to my theme hook which also finds the correct template.
function mytheme_theme() {
  return [
    'node_album_form' =&gt; [
      'template' =&gt; 'node_album_edit_form',
      'path' =&gt; \Drupal::theme()-&gt;getActiveTheme()-&gt;getPath() . '/scss/templates/album',
      'render element' =&gt; 'form'
    ],
  ];
}

In node_album_edit_form.html.twig, I can confirm that changes there alter only the album add/edit form and that I can remove elements with {{ form|without('advanced', 'footer', 'actions') }}, for example.
What I cannot do is placing the form fields where I want them because I'm not using the right reference to the field.
&lt;div class='myfancydiv album-title-field'&gt;{{ field_album_title }}&lt;/div&gt;
&lt;div class='myfancydiv album-artist-field'&gt;{{ field_artist }}&lt;/div&gt;

I tried any of the following, but they didn't work.

{{ field_album_title }}
{{ form.field_album_title }}
{{ album_title }}

How can I reference an entity field in a template file?
Change your hook_theme code to:
function mytheme_theme() {
  return [
    'node_album_edit_form' =&gt; [
      'path' =&gt; \Drupal::theme()-&gt;getActiveTheme()-&gt;getPath() . '/scss/templates/album',
      'render element' =&gt; 'form'
    ],
  ];
}

and in your template file
{{ form.field_album_title }}