Generating arbitrary internal URLs I'm generating the URL inside a controller in a custom module. The URL I generate is to pages on the same site, but not in the module. I want to append an arbitrary number of slugs to the end of the base URL. Some slugs depend on the return values from other API calls, so there's no way to predict how many there are, or what they will be.

I want to generate a $url variable of the form:

'www.base-path-of-website.com'/any/number/of/arbitrary/slugs


I have tried using:

Url::fromRoute() 


But cannot figure out how to get the base route for the website from it. Or how to add arbitrary slugs.

This was trivial in Drupal 7 and earlier, but I cannot find how to do it in Drupal 8. In Drupal 8, how do you generate arbitrary internal URLs from a module?
What should I be doing?
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();