How to create link to a view I've a view with a page display on url "progetti".

On my controller I'm trying to create a link to this url but I can't find the right way. I've added \Drupal\Core\Url namespace on top of the file.

I'm creating an items list:

$url = Url::fromRoute('progetti');
$variables['items'][]['value'] = array(
  '#type' =&gt; 'link',
  '#title' =&gt; array('#value' =&gt; 'sergio'),
  '#url' =&gt; $url,
);


It doesn't work, also if I use "/progetti" as argument.

Logs say:

PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "progetti" does not exist."
As you want to create url object from a path instead of route, use the function fromUri() instead of fromRoute().

$url  = Url::fromUri('internal:/progetti');
$variables['items'][]['value'] = array(
  '#type' =&gt; 'link',
  '#title' =&gt; array('#value' =&gt; 'sergio'),
  '#url' =&gt; $url,
);


In fromUri() function you need to pass the URI of the resource including the scheme. For user input that may correspond to a Drupal route, use internal: for the scheme.