Generating arbitrary internal URLs
From the Drupal API docs for Url::fromRoute()


  Creates a new Url object for a URL that has a Drupal route.
  
  This method is for URLs that have Drupal routes (that is, most pages
  generated by Drupal). For non-routed local URIs relative to the base
  path (like robots.txt) use Url::fromUri() with the base: scheme.


For this method, you need to provide the route name as defined in your module's .routing.yml file, along with an array of parameters in your route: 

\Drupal\Core\Url::fromRoute('mymodule.my_route', array('route_param' =&gt; 'param_value'))-&gt;toString();


Alternatively, if you don't have a route to plug into you can use Url::fromUri() as the docs specified: 

\Drupal\Core\Url::fromUri('base:/any/number/of/arbitrary/slugs',array('absolute' =&gt; TRUE))-&gt;toString();