Render view in code with the proper view mode I have a view that calls for Show: Content, using a very specific view mode (neither Full content nor Teaser, it's created on purpose and themed according to my needs, basically an e-mail oriented output with very different HTML classes than the usual views displays in Drupal). When used in a page, it renders perfectly. However, when I render it from code to be able to use the resulting HTML directly:

$view = Views::getView('view_id');
$view-&gt;setDisplay('default');
$view-&gt;setArguments($args);
$view-&gt;preExecute();
$view-&gt;execute();
$render = $view-&gt;render();
$html = render($render);


I get an otherwise perfect render but not with that view mode, just the usual stuff. Alternative calls do the same:

$render = $view-&gt;buildRenderable('default', $args);
$html = render($render);


How could I force it to render the way I want it?
It was the theme. The rendering took place under cron and ran under the administration theme rather than the usual one, meaning different twigs. The solution will be to sub-theme the admin theme to make sure all the relevant twigs are present there, too.