Node values not retrieving properly in .theme and Twig files I created a content type and have a couple of fields: a heading, links, and images.
After creating a node out that content type, I want to pull parts of the node into my homepage. And for that, I used the following in my .themename.theme.

use Drupal\node\Entity\Node;

function amarula_preprocess_page(&amp;$variables) {

    $nid = 62; 
    $node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($nid); 

    $variables['field_vanilla_heading'] = $node-&gt;field_vanilla_heading-&gt;value;
    $variables['field_vanilla_main_content'] = $node-&gt;field_vanilla_main_content-&gt;value;
    $variables['field_vanilla_home_link'] = $node-&gt;field_vanilla_home_link-&gt;value;
    $variables['field_vanilla_home_thumbnail'] = $node-&gt;field_vanilla_home_thumbnail-&gt;value;
}


I get the value of the field_vanilla_heading in my page--front.html.twig

&lt;h1&gt;{{ field_vanilla_heading }}&lt;/h1&gt;


But, the rest of the fields are giving problems.

For the main content {{ field_vanilla_main_content }}, which is long text with summary, I am seeing all the HTML in the page. How can I escape this in twig?

For the rest of the fields, kint tells me that they are null, which is not true:

{{ kint(field_vanilla_home_link) }}
{{ kint(field_vanilla_home_thumbnail) }}


Below is the list of all the field settings:



I can already get the node ID. But how can I get all the values of the node accordingly?
not sure if you still need an answer, but the problem is how you want to retrieve the values from the fields. I get confused all the time, so I usually check out what the column name in the database is of the value I want to get from the field.

Links:

$node-&gt;field_vanilla_home_link-&gt;uri;
$node-&gt;field_vanilla_home_link-&gt;title;


Images are a bit more complicated, maybe there are more ways, but this is how I usually do it:

$entity = $node-&gt;field_vanilla_home_thumbnail-&gt;entity;
    if ($entity) {
      $variables['field_vanilla_home_thumbnail'] = $entity-&gt;getFileUri();
    }


OR with this you could load different image styles (don't forget to import ImageStyle class):

ImageStyle::load('thumbnail')-&gt;buildUrl($entity-&gt;getFileUri());


For the image alt:

$node-&gt;field_vanilla_home_thumbnail-&gt;alt


And I guess you know how to use those values in twig to print links and images (just basic html) :)

Edit: For your problem with your long text with summary, you can filter the markups with "raw":

{{ field_vanilla_main_content | raw }}