How to trim the Node field is rendered in page.html.twig?
We had a similar issue on our site recently. You are trying to print a FieldItemList, which has no __toString function, and therefore cannot be implicitly converted to a string, as you are trying to do.

In your case, node.field_custom appears to be a FieldItemList. I know, you thought it was just a string value from a field -- but it's not. Drupal treats ALL fields as FieldItemLists in the API, even in cases where the field can't possibly contain more than one value. (This presumably makes the implementation cleaner.)



One quick solution to your problem, although this is a bit messy, is to call first(), to get a TypedDataInterface, getValue(), which returns an associative array, and ['value'], in your Twig template, like so:

node.field_custom.first().getValue()['value']


That should return a string. However, for those functions to be accessible in a Twig template, you need to enable them in settings.php and clear the system cache. Here's what worked for us:

$settings['twig_sandbox_whitelisted_methods'] = [
        'first',
        '__toString',
        'bundle',
        'id',
        'label',
];


But in your case, you may have to whitelist more methods to get what you want.

Here is some more information on discovering variables in Twig templates.