Create a link to the fist item of a specific view block I have different view blocks on my front page and they contain number of contents such as images, articles, news etc.

I've managed to get the block list and the block object for each item in that list but how do I fetch the nodes of a view block and generate a link to it programmatically?

$blocks = \Drupal::entityTypeManager()-&gt;getStorage('block')-&gt;loadByProperties(['theme' =&gt; $theme-&gt;getname(), 'region' =&gt; 'content']);
$block_list = array_keys($blocks);

$firstblock = $block_list[0]; // views_block__latest_image_galleries_block_1
// fetch the node list and create the link for first node for $firstblock here.
Since this is a view block, you might be better of directly accessing the view:

$results = views_get_view_result('my_view', 'block1')


Where block1 is the Views display ID. Leave it blank to utilize the default display.

Then

$node = $results[0];
$url = $node-&gt;toUrl()-&gt;toString();
$link = \Drupal::l('My link', $node-&gt;toUrl());